add helper function
This commit is contained in:
parent
ab4b086753
commit
e49346d65d
105
3d.lua
105
3d.lua
@ -2,7 +2,7 @@
|
||||
-- translation support
|
||||
local S = minetest.get_translator("real_torch")
|
||||
|
||||
|
||||
-- flood helper function
|
||||
local function on_flood(pos, oldnode, newnode)
|
||||
|
||||
-- drop as unlit torch
|
||||
@ -38,10 +38,7 @@ minetest.register_node("real_torch:torch", {
|
||||
{
|
||||
name = "real_torch_on_floor.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3
|
||||
type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -99,9 +96,7 @@ minetest.register_node("real_torch:torch", {
|
||||
minetest.set_node(pos, {name = "default:torch", param2 = nod.param2})
|
||||
end,
|
||||
|
||||
floodable = true,
|
||||
on_flood = on_flood,
|
||||
on_rotate = false
|
||||
floodable = true, on_rotate = false, on_flood = on_flood
|
||||
})
|
||||
|
||||
|
||||
@ -113,10 +108,7 @@ minetest.register_node("real_torch:torch_wall", {
|
||||
{
|
||||
name = "real_torch_on_floor.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3
|
||||
type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -144,9 +136,7 @@ minetest.register_node("real_torch:torch_wall", {
|
||||
minetest.set_node(pos, {name = "default:torch_wall", param2 = nod.param2})
|
||||
end,
|
||||
|
||||
floodable = true,
|
||||
on_flood = on_flood,
|
||||
on_rotate = false
|
||||
floodable = true, on_rotate = false, on_flood = on_flood
|
||||
})
|
||||
|
||||
|
||||
@ -158,10 +148,7 @@ minetest.register_node("real_torch:torch_ceiling", {
|
||||
{
|
||||
name = "real_torch_on_floor.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3
|
||||
type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -189,74 +176,36 @@ minetest.register_node("real_torch:torch_ceiling", {
|
||||
minetest.set_node(pos, {name = "default:torch_ceiling", param2 = nod.param2})
|
||||
end,
|
||||
|
||||
floodable = true,
|
||||
on_flood = on_flood,
|
||||
on_rotate = false
|
||||
floodable = true, on_rotate = false, on_flood = on_flood
|
||||
})
|
||||
|
||||
|
||||
-- override default torches to burn out after 8-10 minutes
|
||||
minetest.override_item("default:torch", {
|
||||
-- burnout helper function
|
||||
local function torch_override(name)
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
-- override default torch to burn out after 8-10 minutes
|
||||
minetest.override_item("default:" .. name, {
|
||||
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
on_timer = function(pos, elapsed)
|
||||
|
||||
minetest.set_node(pos, {name = "real_torch:torch", param2 = p2})
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
|
||||
minetest.sound_play("real_torch_burnout",
|
||||
{pos = pos, gain = 0.1, max_hear_distance = 10}, true)
|
||||
end,
|
||||
minetest.set_node(pos, {name = "real_torch:" .. name, param2 = p2})
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.sound_play("real_torch_burnout",
|
||||
{pos = pos, gain = 0.1, max_hear_distance = 10}, true)
|
||||
end,
|
||||
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
|
||||
on_flood = on_flood
|
||||
})
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
|
||||
on_flood = on_flood
|
||||
})
|
||||
end
|
||||
|
||||
minetest.override_item("default:torch_wall", {
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
|
||||
minetest.set_node(pos, {name = "real_torch:torch_wall", param2 = p2})
|
||||
|
||||
minetest.sound_play("real_torch_burnout",
|
||||
{pos = pos, gain = 0.1, max_hear_distance = 10}, true)
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
|
||||
on_flood = on_flood
|
||||
})
|
||||
|
||||
|
||||
minetest.override_item("default:torch_ceiling", {
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
|
||||
minetest.set_node(pos, {name = "real_torch:torch_ceiling", param2 = p2})
|
||||
|
||||
minetest.sound_play("real_torch_burnout",
|
||||
{pos = pos, gain = 0.1, max_hear_distance = 10}, true)
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
|
||||
on_flood = on_flood
|
||||
})
|
||||
torch_override("torch")
|
||||
torch_override("torch_wall")
|
||||
torch_override("torch_ceiling")
|
||||
|
Loading…
x
Reference in New Issue
Block a user