Skip to content

Commit 3294a2a

Browse files
JustinLaw64paramat
authored andcommittedAug 7, 2017
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.
1 parent 5757759 commit 3294a2a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎mods/default/torch.lua

+22-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
3535
3636
--]]
3737

38+
local function on_flood(pos, oldnode, newnode)
39+
minetest.add_item(pos, ItemStack("default:torch 1"))
40+
-- Play flame-extinguish sound if liquid is not an 'igniter'
41+
local nodedef = minetest.registered_items[newnode.name]
42+
if not (nodedef and nodedef.groups and
43+
nodedef.groups.igniter and nodedef.groups.igniter > 0) then
44+
minetest.sound_play(
45+
"default_cool_lava",
46+
{pos = pos, max_hear_distance = 16, gain = 0.1}
47+
)
48+
end
49+
-- Remove the torch node
50+
return false
51+
end
52+
3853
minetest.register_node("default:torch", {
3954
description = "Torch",
4055
drawtype = "mesh",
@@ -83,7 +98,9 @@ minetest.register_node("default:torch", {
8398
itemstack:set_name("default:torch")
8499

85100
return itemstack
86-
end
101+
end,
102+
floodable = true,
103+
on_flood = on_flood,
87104
})
88105

89106
minetest.register_node("default:torch_wall", {
@@ -105,6 +122,8 @@ minetest.register_node("default:torch_wall", {
105122
wall_side = {-1/2, -1/2, -1/8, -1/8, 1/8, 1/8},
106123
},
107124
sounds = default.node_sound_wood_defaults(),
125+
floodable = true,
126+
on_flood = on_flood,
108127
})
109128

110129
minetest.register_node("default:torch_ceiling", {
@@ -126,6 +145,8 @@ minetest.register_node("default:torch_ceiling", {
126145
wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8},
127146
},
128147
sounds = default.node_sound_wood_defaults(),
148+
floodable = true,
149+
on_flood = on_flood,
129150
})
130151

131152
minetest.register_lbm({

0 commit comments

Comments
 (0)
Please sign in to comment.