Initial release

This commit is contained in:
whosit 2025-03-02 17:34:56 +03:00
parent 5085276f3e
commit 9e9b52466b
9 changed files with 109 additions and 35 deletions

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2025 whosit
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# compass_rose
A simple 3x3 node that can be used as a compass rose decal placed on top of other nodes.
Auto-rotates to point in the correct direction, most of the times.
If anyone finds disabled rotation too limiting, ask Alias to fix it.
## Thank you
* Simson (Alias' cat)

Binary file not shown.

19
init.lua Normal file
View File

@ -0,0 +1,19 @@
local mod_start_time = core.get_us_time()
core.log("action", "[MOD] compass_rose loading")
compass_rose_node = {}
compass_rose_node.error = {}
local modpath = core.get_modpath("compass_rose") .. DIR_DELIM
compass_rose_node.information = {}
compass_rose_node.information.version = "0.1"
compass_rose_node.information.author = "whosit"
compass_rose_node.information.license = "MIT"
compass_rose_node.information.name = "Adds compass rose blocks"
compass_rose_node.information.source = "https://gitea.your-land.de/whosit/compass_rose"
compass_rose_node.information.additional = "Adds a 'compass rose' decal."
dofile(modpath .. "internal.lua")
local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000
core.log("action", "[MOD] compass_rose loaded in [" .. mod_end_time .. "s]")

66
internal.lua Normal file
View File

@ -0,0 +1,66 @@
local function on_place(itemstack, placer, pointed_thing)
if not minetest.is_player(placer) then
return minetest.item_place(itemstack, placer, pointed_thing)
end
local look_dir = placer:get_look_dir()
if not vector.check(look_dir) then
return minetest.item_place(itemstack, placer, pointed_thing)
end
local facedir = minetest.dir_to_facedir(look_dir)
local aim_dir = pointed_thing.under - pointed_thing.above
local param2 = 20 + math.random(0, 3) -- random rotation for the "upside-down" position
if aim_dir.y == -1 then
param2 = 0
elseif aim_dir.x == 1 then
param2 = 16
elseif aim_dir.x == -1 then
param2 = 12
elseif aim_dir.z == 1 then
param2 = 8
elseif aim_dir.z == -1 then
param2 = 4
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end
minetest.register_node(":compass_rose:decal", {
description = "Compass rose decal",
drawtype = "nodebox",
use_texture_alpha = "blend",
tiles = {
"compass_rose_decal.png",
"blank.png",
"blank.png",
"blank.png",
"blank.png",
"blank.png",
},
visual_scale = 3.0,
is_ground_content = false,
inventory_image = "compass_rose_decal.png",
wield_image = "compass_rose_decal.png",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
climbable = false,
sunlight_propagates = true,
node_box = {
type = "fixed",
-- shift tiny bit upwards (0.49) to prevent z-fighting
fixed = {-1.5/3, -0.5/3, -1.5/3, 1.5/3, -0.49/3, 1.5/3}
},
selection_box = {
type = "fixed",
fixed = {-1.5, -0.45, -1.5, 1.5, -0.5, 1.5}
},
groups = {choppy = 3, dig_immediate = 2},
on_place = on_place,
on_rotate = false, -- probably disable rotations
})

View File

@ -1,35 +0,0 @@
# crop 3x3 image into 6: corner, center, and 4 directions (only top-left corner is used)
import os
print(os.getcwd())
import krita
currentDocument = Krita.instance().activeDocument()
import os.path
filepath = currentDocument.fileName()
filename = os.path.splitext(os.path.basename(filepath))[0]
dir = os.path.dirname(filepath)
print(dir)
currentDocument.setBatchmode(True)
s = 16
corners = [
[0,0], [s,0],
[0,s], [s, s], [s*2, s],
[s, s*2],
]
for i,c in enumerate(corners):
clone = currentDocument.clone()
print(c[0], c[1])
clone.crop(c[0], c[1], s, s)
exportParameters =krita.InfoObject()
exportParameters.setProperty("alpha", True)
exportParameters.setProperty("compression", 6) # 0-9
exportParameters.setProperty("indexed", False)
res = clone.exportImage(os.path.join(dir, f"{filename}_side{i}.png"), exportParameters)
clone.close()
print(res)
if not res:
break
currentDocument.setBatchmode(False)

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = compass_rose
description = Adds a compass rose decal.
author = whosit
title = Compass rose decal

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B