TNT: Gunpowder (and tnt.burn) will trigger the on_ignite of nodes
authorFernando Carmona Varo <ferkiwi@gmail.com>
Sun, 13 Nov 2016 15:08:07 +0000 (16:08 +0100)
committerparamat <mat.gregory@virginmedia.com>
Mon, 1 May 2017 18:38:38 +0000 (19:38 +0100)
The previous behaviour is kept as fallback for compatibility, for when the on_ignite
is not defined in the node.

game_api.txt
mods/tnt/init.lua

index 8b6bf8399fccf89214ad26b6102912fd92cae25d..887f394e28f4f0e84ed6687e6c191f990d30db11 100644 (file)
@@ -312,8 +312,10 @@ TNT API
 
 `tnt.burn(position, [nodename])`
 
-^ Ignite TNT at position, nodename isn't required unless already known.
-
+^ Ignite node at position, triggering its `on_ignite` callback (see fire mod).
+If no such callback exists, fallback to turn tnt group nodes to their
+"_burning" variant.
+  nodename isn't required unless already known.
 
 To make dropping items from node inventories easier, you can use the
 following helper function from 'default':
index 9870f891e3fc702d90a93750481e9bd72c256f9f..e5ad5b166f8a8d2e624ba5d9a3d82640bf9389da 100644 (file)
@@ -260,13 +260,15 @@ end
 
 function tnt.burn(pos, nodename)
        local name = nodename or minetest.get_node(pos).name
-       local group = minetest.get_item_group(name, "tnt")
-       if group > 0 then
+       local def = minetest.registered_nodes[name]
+       if not def then
+               return
+       elseif def.on_ignite then
+               def.on_ignite(pos)
+       elseif minetest.get_item_group(name, "tnt") > 0 then
                minetest.sound_play("tnt_ignite", {pos = pos})
                minetest.set_node(pos, {name = name .. "_burning"})
                minetest.get_node_timer(pos):start(1)
-       elseif name == "tnt:gunpowder" then
-               minetest.set_node(pos, {name = "tnt:gunpowder_burning"})
        end
 end