mesecons/mesecons_delayer/init.lua

308 lines
9.0 KiB
Lua
Raw Normal View History

2012-03-29 22:11:17 +02:00
minetest.register_node("mesecons_delayer:delayer_off_1", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_off_1.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_off_1.png",
2012-04-02 08:41:27 +02:00
wield_image = "mesecons_delayer_off_1.png",
2012-03-29 22:11:17 +02:00
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-03-29 22:11:17 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2},
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_off_2", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_off_2.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_off_2.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_off_3", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_off_3.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_off_3.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_off_4", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_off_4.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_off_4.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_on_1", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_on_1.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_on_1.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_on_2", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_on_2.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_on_2.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_on_3", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_on_3.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_on_3.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_node("mesecons_delayer:delayer_on_4", {
description = "Delayer",
2012-06-21 20:33:01 +02:00
drawtype = "nodebox",
tiles = {
"mesecons_delayer_on_4.png",
"mesecons_delayer_sides.png"
},
2012-03-29 22:11:17 +02:00
inventory_image = "mesecons_delayer_on_4.png",
walkable = false,
2012-06-21 20:33:01 +02:00
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
},
2012-08-01 11:58:19 +02:00
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1},
2012-03-29 22:11:17 +02:00
paramtype = "light",
2012-06-21 20:33:01 +02:00
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
2012-03-29 22:11:17 +02:00
drop = 'mesecons_delayer:delayer_off_1',
})
minetest.register_on_punchnode(function (pos, node)
if node.name=="mesecons_delayer:delayer_off_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2"})
end
if node.name=="mesecons_delayer:delayer_off_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3"})
end
if node.name=="mesecons_delayer:delayer_off_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4"})
end
if node.name=="mesecons_delayer:delayer_off_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1"})
end
end)
minetest.register_on_punchnode(function (pos, node)
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2"})
end
if node.name=="mesecons_delayer:delayer_on_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3"})
end
if node.name=="mesecons_delayer:delayer_on_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4"})
end
if node.name=="mesecons_delayer:delayer_on_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1"})
end
end)
mesecon.delayer_signal_change = function(pos, node)
if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then
np={x=pos.x-1, y=pos.y, z=pos.z}
nn=minetest.env:get_node(np)
if nn.name=="mesecons:mesecon_on" or mesecon:is_receptor_node(nn.name, np, pos) then
local time
if node.name=="mesecons_delayer:delayer_off_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1"})
2012-04-06 20:03:12 +02:00
time=0.1
2012-03-29 22:11:17 +02:00
end
if node.name=="mesecons_delayer:delayer_off_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2"})
2012-04-06 20:03:12 +02:00
time=0.3
2012-03-29 22:11:17 +02:00
end
if node.name=="mesecons_delayer:delayer_off_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3"})
2012-04-06 20:03:12 +02:00
time=0.5
2012-03-29 22:11:17 +02:00
end
if node.name=="mesecons_delayer:delayer_off_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4"})
2012-04-06 20:03:12 +02:00
time=1
2012-03-29 22:11:17 +02:00
end
minetest.after(time, mesecon.delayer_turnon, {pos=pos})
end
end
if string.find(node.name, "mesecons_delayer:delayer_on")~=nil then
np={x=pos.x-1, y=pos.y, z=pos.z}
nn=minetest.env:get_node(np)
if nn.name=="mesecons:mesecon_off" or mesecon:is_receptor_node_off(nn.name, np, pos) or nn.name=="air" then
local time
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1"})
2012-04-06 20:03:12 +02:00
time=0.1
2012-03-29 22:11:17 +02:00
end
if node.name=="mesecons_delayer:delayer_on_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2"})
2012-04-06 20:03:12 +02:00
time=0.3
2012-03-29 22:11:17 +02:00
end
if node.name=="mesecons_delayer:delayer_on_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3"})
2012-04-06 20:03:12 +02:00
time=0.5
2012-03-29 22:11:17 +02:00
end
if node.name=="mesecons_delayer:delayer_on_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4"})
2012-04-06 20:03:12 +02:00
time=1
2012-03-29 22:11:17 +02:00
end
minetest.after(time, mesecon.delayer_turnoff, {pos=pos})
end
end
end
mesecon:register_on_signal_change(mesecon.delayer_signal_change)
mesecon.delayer_turnon=function(params)
mesecon:receptor_on(params.pos, mesecon:get_rules("delayer"))
end
mesecon.delayer_turnoff=function(params)
mesecon:receptor_off(params.pos, mesecon:get_rules("delayer"))
end
mesecon:add_rules("delayer", {{x=1, y=0, z=0}})
mesecon:add_receptor_node("mesecons_delayer:delayer_on_1", mesecon:get_rules("delayer"))
mesecon:add_receptor_node("mesecons_delayer:delayer_on_2", mesecon:get_rules("delayer"))
mesecon:add_receptor_node("mesecons_delayer:delayer_on_3", mesecon:get_rules("delayer"))
mesecon:add_receptor_node("mesecons_delayer:delayer_on_4", mesecon:get_rules("delayer"))
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_1", mesecon:get_rules("delayer"))
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_2", mesecon:get_rules("delayer"))
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_3", mesecon:get_rules("delayer"))
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_4", mesecon:get_rules("delayer"))