Skip to content

Commit

Permalink
Torches: Make liquids drop torches as items
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JustinLaw64 authored and paramat committed Aug 7, 2017
1 parent 5757759 commit 3294a2a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion mods/default/torch.lua
Expand Up @@ -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",
Expand Down Expand Up @@ -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", {
Expand All @@ -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", {
Expand All @@ -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({
Expand Down

0 comments on commit 3294a2a

Please sign in to comment.