Add register_on_nodeload()
This commit is contained in:
parent
a654b9b748
commit
12ab6213f3
7
mods/nodes/api.md
Normal file
7
mods/nodes/api.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Node mod API
|
||||
|
||||
```lua
|
||||
nodes.register_on_nodeload(function(pos, node)
|
||||
-- Do stuff to a schematic node after it's been constructed for the first time
|
||||
end)
|
||||
```
|
@ -1,4 +1,10 @@
|
||||
nodes = {}
|
||||
nodes = {
|
||||
registered_on_loadnode = {}
|
||||
}
|
||||
|
||||
function nodes.register_on_nodeload(func)
|
||||
table.insert(nodes.registered_on_loadnode, func)
|
||||
end
|
||||
|
||||
minetest.register_lbm({ -- Loads nodes placed by schematics that have meta
|
||||
label = "Load special nodes placed by schematics",
|
||||
@ -9,6 +15,12 @@ minetest.register_lbm({ -- Loads nodes placed by schematics that have meta
|
||||
if minetest.get_meta(pos):get_int("loaded") ~= 0 then return end -- Already loaded
|
||||
|
||||
minetest.registered_nodes[node.name].on_construct(pos)
|
||||
|
||||
for _, func in ipairs(nodes.registered_on_loadnode) do
|
||||
if func(pos, node) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user