From: ForbiddenJ Date: Tue, 25 Jul 2017 18:52:39 +0000 (-0500) Subject: Torches: Make liquids drop torches as items X-Git-Tag: 5.0.0~194 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3294a2a51549a32b9703e3a4d2346b7fe1b2756c;p=oweals%2Fminetest_game.git Torches: Make liquids drop torches as items Liquids that are 'igniters', such as lava, will drop the torch without a flame-extinguish sound, as the torch item will burn up after a few seconds with a sound and smoke particles. All other liquids cause a flame-extinguish sound. --- diff --git a/mods/default/torch.lua b/mods/default/torch.lua index 3c3ae965..016ae685 100644 --- a/mods/default/torch.lua +++ b/mods/default/torch.lua @@ -35,6 +35,21 @@ See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt --]] +local function on_flood(pos, oldnode, newnode) + minetest.add_item(pos, ItemStack("default:torch 1")) + -- Play flame-extinguish sound if liquid is not an 'igniter' + local nodedef = minetest.registered_items[newnode.name] + if not (nodedef and nodedef.groups and + nodedef.groups.igniter and nodedef.groups.igniter > 0) then + minetest.sound_play( + "default_cool_lava", + {pos = pos, max_hear_distance = 16, gain = 0.1} + ) + end + -- Remove the torch node + return false +end + minetest.register_node("default:torch", { description = "Torch", drawtype = "mesh", @@ -83,7 +98,9 @@ minetest.register_node("default:torch", { itemstack:set_name("default:torch") return itemstack - end + end, + floodable = true, + on_flood = on_flood, }) minetest.register_node("default:torch_wall", { @@ -105,6 +122,8 @@ minetest.register_node("default:torch_wall", { wall_side = {-1/2, -1/2, -1/8, -1/8, 1/8, 1/8}, }, sounds = default.node_sound_wood_defaults(), + floodable = true, + on_flood = on_flood, }) minetest.register_node("default:torch_ceiling", { @@ -126,6 +145,8 @@ minetest.register_node("default:torch_ceiling", { wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8}, }, sounds = default.node_sound_wood_defaults(), + floodable = true, + on_flood = on_flood, }) minetest.register_lbm({