code tidy and tweak
This commit is contained in:
parent
c3969b1c64
commit
f2ea1dfaa5
35
3d.lua
35
3d.lua
@ -1,24 +1,21 @@
|
||||
|
||||
local function on_flood(pos, oldnode, newnode)
|
||||
|
||||
-- drop as unlit torch
|
||||
minetest.add_item(pos, ItemStack("real_torch:torch 1"))
|
||||
|
||||
-- Play flame-extinguish sound if liquid is not an 'igniter'
|
||||
local nodedef = minetest.registered_items[newnode.name]
|
||||
|
||||
-- return if torch is unlit already
|
||||
if oldnode.name == "real_torch:torch"
|
||||
or oldnode.name == "real_torch:torch_wall"
|
||||
or oldnode.name == "real_torch:torch_ceiling" then
|
||||
if oldnode.name:find("real_torch:") then
|
||||
return false
|
||||
end
|
||||
|
||||
-- play sound if torch is lit
|
||||
if not (nodedef and nodedef.groups and nodedef.groups.igniter
|
||||
and nodedef.groups.igniter > 0) then
|
||||
local def = minetest.registered_items[newnode.name]
|
||||
|
||||
-- play extinquish sound if lit torch put out by water
|
||||
if def and def.groups and def.groups.water and def.groups.water > 0 then
|
||||
|
||||
minetest.sound_play("default_cool_lava",
|
||||
{pos = pos, max_hear_distance = 16, gain = 0.1}, true)
|
||||
{pos = pos, max_hear_distance = 10, gain = 0.1}, true)
|
||||
end
|
||||
|
||||
-- Remove the torch node
|
||||
@ -65,8 +62,10 @@ minetest.register_node("real_torch:torch", {
|
||||
local node = minetest.get_node(under)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
|
||||
if def and def.on_rightclick and
|
||||
((not placer) or (placer and not placer:get_player_control().sneak)) then
|
||||
if def and def.on_rightclick
|
||||
and not (placer and placer:is_player()
|
||||
and placer:get_player_control().sneak) then
|
||||
|
||||
return def.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
@ -97,7 +96,8 @@ minetest.register_node("real_torch:torch", {
|
||||
end,
|
||||
|
||||
floodable = true,
|
||||
on_flood = on_flood
|
||||
on_flood = on_flood,
|
||||
on_rotate = false
|
||||
})
|
||||
|
||||
|
||||
@ -141,7 +141,8 @@ minetest.register_node("real_torch:torch_wall", {
|
||||
end,
|
||||
|
||||
floodable = true,
|
||||
on_flood = on_flood
|
||||
on_flood = on_flood,
|
||||
on_rotate = false
|
||||
})
|
||||
|
||||
|
||||
@ -185,7 +186,8 @@ minetest.register_node("real_torch:torch_ceiling", {
|
||||
end,
|
||||
|
||||
floodable = true,
|
||||
on_flood = on_flood
|
||||
on_flood = on_flood,
|
||||
on_rotate = false
|
||||
})
|
||||
|
||||
|
||||
@ -203,6 +205,7 @@ minetest.override_item("default:torch", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
@ -224,6 +227,7 @@ minetest.override_item("default:torch_wall", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
@ -245,6 +249,7 @@ minetest.override_item("default:torch_ceiling", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
|
7
init.lua
7
init.lua
@ -145,7 +145,7 @@ local function add_effects(pos, radius)
|
||||
})
|
||||
|
||||
minetest.sound_play("tnt_explode",
|
||||
{pos = pos, gain = 0.1, max_hear_distance = 5}, true)
|
||||
{pos = pos, gain = 0.1, max_hear_distance = 10}, true)
|
||||
end
|
||||
|
||||
|
||||
@ -198,7 +198,10 @@ minetest.override_item("tnt:gunpowder", {
|
||||
|
||||
-- small delay to fix dupe bug
|
||||
minetest.after(0.1, function(user)
|
||||
user:set_hp(user:get_hp() - 2)
|
||||
|
||||
if user and user:get_pos() then
|
||||
user:set_hp(user:get_hp() - 2)
|
||||
end
|
||||
end, user)
|
||||
|
||||
add_effects(pos, 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user