Add on_burn code that happens upon burning.

This commit is contained in:
HybridDog 2016-02-11 17:40:20 +01:00
parent 31c88df258
commit 6be732e432
2 changed files with 16 additions and 0 deletions

View file

@ -178,6 +178,9 @@ farming.register_plant(name, Plant definition)
Fire API
----------
Add group flammable when registering a node to make fire seek for it.
Add on_burn to nodedef to do sth different than simply removing the flammable node:
If on_burn is a string, then the node gets replaced with on_burn,
else on_burn is a function with the params pos and node, if it returns false, the node will be removed.
Screwdriver API
---------------

View file

@ -207,6 +207,19 @@ else
if not p then
return
end
local node = minetest.get_node(p)
local on_burn = minetest.registered_nodes[node.name].on_burn
if on_burn then
if type(on_burn) == "string" then
node.name = on_burn
minetest.set_node(p, node)
nodeupdate(p)
return
end
if on_burn(p, node) ~= false then
return
end
end
minetest.remove_node(p)
nodeupdate(p)
end,