Skip to content
Permalink
Browse files

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.
  • Loading branch information
ForbiddenJ authored and paramat committed Aug 7, 2017
1 parent 5757759 commit 3294a2a51549a32b9703e3a4d2346b7fe1b2756c
Showing with 22 additions and 1 deletion.
  1. +22 −1 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({

0 comments on commit 3294a2a

Please sign in to comment.