From 8259231013892bd081d1f4097eac9ea32bfe7a8b Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Sat, 21 Oct 2023 11:47:12 +0200 Subject: [PATCH 1/2] fix error in decomposing leaves placement. one place accidentally used the position of the placed node, when it should have used the position below that. --- mods/bg_tree/node_leaves.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/bg_tree/node_leaves.lua b/mods/bg_tree/node_leaves.lua index e983329..08afa97 100644 --- a/mods/bg_tree/node_leaves.lua +++ b/mods/bg_tree/node_leaves.lua @@ -77,7 +77,7 @@ local function after_place_stack (pos) local below = pos + blockgame.vector.dirs.down if check_decompose(below) then local node = minetest.get_node(pos) - local below_node = minetest.get_node(pos) + local below_node = minetest.get_node(below) local def = minetest.registered_nodes[node.name] local below_def = minetest.registered_nodes[below_node.name] From f228dcac5339dbd20a618cc86888e797fdb3af4c Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Sat, 21 Oct 2023 11:56:50 +0200 Subject: [PATCH 2/2] fix name validations in `register_node` wrapper. `blockgame.register_node` now works both when the provided name includes a mod name, and when it doesn't. previously, including a mod name would break things, making the actual name used for registration include the mod name twice. --- mods/bg_api/wrappers.lua | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/mods/bg_api/wrappers.lua b/mods/bg_api/wrappers.lua index c22e6fc..437adce 100644 --- a/mods/bg_api/wrappers.lua +++ b/mods/bg_api/wrappers.lua @@ -34,28 +34,40 @@ end local events = blockgame.events.namespace("api") -function blockgame.register_node (name, def, modname) - -- TODO: take full name and then extract modname and base name from that, that'll probably be easier to maintain. - -- (if no modname is provided, still assume it like what is being done currently.) - local modname = modname or minetest.get_current_modname() - local full_name = modname .. ":" .. name +function blockgame.register_node (fullname, def) + -- make sure the right names are used in the right contexts, by manually extracting them here. + -- this makes `blockgame.register_node` more flexible/reliable. + local modname + local basename - def.description = def.description or capitalize(name) + local colon_pos = string.find(fullname, ":") + if colon_pos then + modname = string.sub(fullname, 1, colon_pos - 1) + basename = string.sub(fullname, colon_pos + 1) + else + modname = minetest.get_current_modname() + basename = fullname + fullname = modname .. ":" .. basename + end + + def.description = def.description or capitalize(basename) def.tiles = def.tiles or { - modname .. "_" .. name .. ".png", + modname .. "_" .. basename .. ".png", } events.broadcast("before_register_node", { - name = name, + name = fullname, def = def, mod = modname, + basename = basename }) - minetest.register_node(full_name, def) + minetest.register_node(fullname, def) events.broadcast("after_register_node", { - name = name, + name = fullname, def = def, mod = modname, + basename = basename }) end