make blockgame.register_node
wrapper emit events.
the api function `blockgame.register_node` will now emit events before and after registering a node, allowing for other code to react to and affect node registration.
This commit is contained in:
parent
09bcf2260b
commit
968ae04b3a
1 changed files with 14 additions and 0 deletions
|
@ -32,6 +32,8 @@ local function capitalize (str)
|
||||||
return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2)
|
return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local events = blockgame.events.namespace("api")
|
||||||
|
|
||||||
function blockgame.register_node (name, def)
|
function blockgame.register_node (name, def)
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
local full_name = modname .. ":" .. name
|
local full_name = modname .. ":" .. name
|
||||||
|
@ -41,5 +43,17 @@ function blockgame.register_node (name, def)
|
||||||
modname .. "_" .. name .. ".png",
|
modname .. "_" .. name .. ".png",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.broadcast("before_register_node", {
|
||||||
|
name = name,
|
||||||
|
def = def,
|
||||||
|
mod = modname,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node(full_name, def)
|
minetest.register_node(full_name, def)
|
||||||
|
|
||||||
|
events.broadcast("after_register_node", {
|
||||||
|
name = name,
|
||||||
|
def = def,
|
||||||
|
mod = modname,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue