Merge branch 'main' into leveled-nodes
This commit is contained in:
commit
29017dd835
2 changed files with 23 additions and 11 deletions
|
@ -34,28 +34,40 @@ end
|
||||||
|
|
||||||
local events = blockgame.events.namespace("api")
|
local events = blockgame.events.namespace("api")
|
||||||
|
|
||||||
function blockgame.register_node (name, def, modname)
|
function blockgame.register_node (fullname, def)
|
||||||
-- TODO: take full name and then extract modname and base name from that, that'll probably be easier to maintain.
|
-- make sure the right names are used in the right contexts, by manually extracting them here.
|
||||||
-- (if no modname is provided, still assume it like what is being done currently.)
|
-- this makes `blockgame.register_node` more flexible/reliable.
|
||||||
local modname = modname or minetest.get_current_modname()
|
local modname
|
||||||
local full_name = modname .. ":" .. name
|
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 {
|
def.tiles = def.tiles or {
|
||||||
modname .. "_" .. name .. ".png",
|
modname .. "_" .. basename .. ".png",
|
||||||
}
|
}
|
||||||
|
|
||||||
events.broadcast("before_register_node", {
|
events.broadcast("before_register_node", {
|
||||||
name = name,
|
name = fullname,
|
||||||
def = def,
|
def = def,
|
||||||
mod = modname,
|
mod = modname,
|
||||||
|
basename = basename
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(full_name, def)
|
minetest.register_node(fullname, def)
|
||||||
|
|
||||||
events.broadcast("after_register_node", {
|
events.broadcast("after_register_node", {
|
||||||
name = name,
|
name = fullname,
|
||||||
def = def,
|
def = def,
|
||||||
mod = modname,
|
mod = modname,
|
||||||
|
basename = basename
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,7 +81,7 @@ local function after_place_stack (pos)
|
||||||
local below = pos + blockgame.vector.dirs.down
|
local below = pos + blockgame.vector.dirs.down
|
||||||
if check_decompose(below) then
|
if check_decompose(below) then
|
||||||
local node = minetest.get_node(pos)
|
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 def = minetest.registered_nodes[node.name]
|
||||||
local below_def = minetest.registered_nodes[below_node.name]
|
local below_def = minetest.registered_nodes[below_node.name]
|
||||||
|
|
Loading…
Reference in a new issue