From: red-001 Date: Wed, 20 Jan 2016 22:18:03 +0000 (+0000) Subject: Add an on_burn callback. X-Git-Tag: 0.4.14~104 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a5ad30748de460b0309b106370cc953e4ccfefe5;p=oweals%2Fminetest_game.git Add an on_burn callback. --- diff --git a/game_api.txt b/game_api.txt index 4ee23f09..6944d580 100644 --- a/game_api.txt +++ b/game_api.txt @@ -176,6 +176,14 @@ The farming API allows you to easily register plants and hoes. maxlight = default.LIGHT_MAX -- Maximum light to grow } +Fire API +-------- + +`on_burn(pos)` + + * Called when fire attempts to remove a burning node. + * `pos` Position of the burning node. + Screwdriver API --------------- @@ -451,4 +459,4 @@ Trees * Grows a new design aspen tree at pos * `default.grow_new_snowy_pine_tree(pos)` - * Grows a new design snowy pine tree at pos \ No newline at end of file + * Grows a new design snowy pine tree at pos diff --git a/mods/fire/init.lua b/mods/fire/init.lua index a5566628..28f68e98 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -235,8 +235,14 @@ else -- remove flammable nodes around flame local p = minetest.find_node_near(p0, 1, {"group:flammable"}) if p then - minetest.remove_node(p) - nodeupdate(p) + local node = minetest.get_node(p) + local def = minetest.registered_nodes[node.name] + if def.on_burn then + def.on_burn(p) + else + minetest.remove_node(p) + nodeupdate(p) + end end end end,