From be9121214caf2de50a9371321357283a1c17f48a Mon Sep 17 00:00:00 2001 From: Fernando Carmona Varo Date: Sun, 13 Nov 2016 16:08:07 +0100 Subject: [PATCH] TNT: Gunpowder (and tnt.burn) will trigger the on_ignite of nodes The previous behaviour is kept as fallback for compatibility, for when the on_ignite is not defined in the node. --- game_api.txt | 6 ++++-- mods/tnt/init.lua | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/game_api.txt b/game_api.txt index 8b6bf83..887f394 100644 --- a/game_api.txt +++ b/game_api.txt @@ -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': diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 9870f89..e5ad5b1 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -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