2013-12-18 21:14:03 +01:00
|
|
|
local vertical_box = {
|
2012-12-13 18:42:45 +01:00
|
|
|
type = "fixed",
|
2013-12-18 21:14:03 +01:00
|
|
|
fixed = {-1/16, -8/16, -1/16, 1/16, 8/16, 1/16}
|
2012-12-13 18:42:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 21:14:03 +01:00
|
|
|
local top_box = {
|
2012-12-13 18:42:45 +01:00
|
|
|
type = "fixed",
|
2013-12-18 21:14:03 +01:00
|
|
|
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16}}
|
2012-12-13 18:42:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 21:14:03 +01:00
|
|
|
local bottom_box = {
|
2012-12-13 18:42:45 +01:00
|
|
|
type = "fixed",
|
2013-12-18 21:14:03 +01:00
|
|
|
fixed = {
|
|
|
|
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
|
|
|
|
{-1/16, -7/16, -1/16, 1/16, 8/16, 1/16},
|
|
|
|
}
|
2012-12-13 18:42:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 21:14:03 +01:00
|
|
|
local vertical_rules = {
|
|
|
|
{x=0, y=1, z=0},
|
2014-11-22 12:28:45 +01:00
|
|
|
{x=0, y=-1, z=0}
|
2013-12-18 21:14:03 +01:00
|
|
|
}
|
2012-12-13 18:42:45 +01:00
|
|
|
|
2013-12-18 21:14:03 +01:00
|
|
|
local top_rules = {
|
|
|
|
{x=1,y=0, z=0},
|
|
|
|
{x=-1,y=0, z=0},
|
|
|
|
{x=0,y=0, z=1},
|
|
|
|
{x=0,y=0, z=-1},
|
2014-11-22 12:28:45 +01:00
|
|
|
{x=0,y=-1, z=0}
|
2013-12-18 21:14:03 +01:00
|
|
|
}
|
2012-12-13 18:42:45 +01:00
|
|
|
|
2013-12-18 21:14:03 +01:00
|
|
|
local bottom_rules = {
|
|
|
|
{x=1, y=0, z=0},
|
|
|
|
{x=-1, y=0, z=0},
|
|
|
|
{x=0, y=0, z=1},
|
|
|
|
{x=0, y=0, z=-1},
|
|
|
|
{x=0, y=1, z=0},
|
2014-11-22 12:28:45 +01:00
|
|
|
{x=0, y=2, z=0} -- receive power from pressure plate / detector / ... 2 nodes above
|
2013-12-18 21:14:03 +01:00
|
|
|
}
|
2012-12-13 18:42:45 +01:00
|
|
|
|
|
|
|
local vertical_updatepos = function (pos)
|
2013-12-01 02:43:30 +01:00
|
|
|
local node = minetest.get_node(pos)
|
2014-11-22 12:28:45 +01:00
|
|
|
if minetest.registered_nodes[node.name]
|
|
|
|
and minetest.registered_nodes[node.name].is_vertical_conductor then
|
2014-11-22 15:42:22 +01:00
|
|
|
local node_above = minetest.get_node(mesecon.addPosRule(pos, vertical_rules[1]))
|
|
|
|
local node_below = minetest.get_node(mesecon.addPosRule(pos, vertical_rules[2]))
|
2012-12-13 18:42:45 +01:00
|
|
|
local namestate = minetest.registered_nodes[node.name].vertical_conductor_state
|
|
|
|
|
2014-11-22 12:28:45 +01:00
|
|
|
local above = minetest.registered_nodes[node_above.name]
|
|
|
|
and minetest.registered_nodes[node_above.name].is_vertical_conductor
|
|
|
|
local below = minetest.registered_nodes[node_below.name]
|
|
|
|
and minetest.registered_nodes[node_below.name].is_vertical_conductor
|
2012-12-13 18:42:45 +01:00
|
|
|
|
2014-11-22 12:28:45 +01:00
|
|
|
local basename = "mesecons_extrawires:vertical_"
|
2013-06-22 21:43:58 +02:00
|
|
|
if above and below then -- above and below: vertical mesecon
|
2014-11-22 12:28:45 +01:00
|
|
|
minetest.add_node(pos, {name = basename .. namestate})
|
2013-06-22 21:43:58 +02:00
|
|
|
elseif above and not below then -- above only: bottom
|
2014-11-22 12:28:45 +01:00
|
|
|
minetest.add_node(pos, {name = basename .. "bottom_" .. namestate})
|
2013-06-22 21:43:58 +02:00
|
|
|
elseif not above and below then -- below only: top
|
2014-11-22 12:28:45 +01:00
|
|
|
minetest.add_node(pos, {name = basename .. "top_" .. namestate})
|
|
|
|
else -- no vertical wire above, no vertical wire below: use bottom
|
|
|
|
minetest.add_node(pos, {name = basename .. "bottom_" .. namestate})
|
2012-12-13 18:42:45 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local vertical_update = function (pos, node)
|
|
|
|
vertical_updatepos(pos) -- this one
|
2014-11-22 15:42:22 +01:00
|
|
|
vertical_updatepos(mesecon.addPosRule(pos, vertical_rules[1])) -- above
|
|
|
|
vertical_updatepos(mesecon.addPosRule(pos, vertical_rules[2])) -- below
|
2012-12-13 18:42:45 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Vertical wire
|
2014-11-22 12:28:45 +01:00
|
|
|
mesecon.register_node("mesecons_extrawires:vertical", {
|
2012-12-13 18:42:45 +01:00
|
|
|
description = "Vertical mesecon",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
walkable = false,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
2013-12-18 21:14:03 +01:00
|
|
|
selection_box = vertical_box,
|
|
|
|
node_box = vertical_box,
|
2012-12-13 18:42:45 +01:00
|
|
|
is_vertical_conductor = true,
|
2013-12-01 02:43:30 +01:00
|
|
|
drop = "mesecons_extrawires:vertical_off",
|
2013-12-18 21:14:03 +01:00
|
|
|
after_place_node = vertical_update,
|
2014-11-22 12:28:45 +01:00
|
|
|
after_dig_node = vertical_update
|
|
|
|
},{
|
2014-11-22 11:37:47 +01:00
|
|
|
tiles = {"mesecons_wire_off.png"},
|
2013-12-18 21:14:03 +01:00
|
|
|
groups = {dig_immediate=3},
|
2012-12-13 18:42:45 +01:00
|
|
|
vertical_conductor_state = "off",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
onstate = "mesecons_extrawires:vertical_on",
|
2013-12-18 21:14:03 +01:00
|
|
|
rules = vertical_rules,
|
2014-11-22 12:28:45 +01:00
|
|
|
}}
|
|
|
|
},{
|
2014-11-22 11:37:47 +01:00
|
|
|
tiles = {"mesecons_wire_on.png"},
|
2013-12-18 21:14:03 +01:00
|
|
|
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
2012-12-13 18:42:45 +01:00
|
|
|
vertical_conductor_state = "on",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = mesecon.state.on,
|
2014-11-22 12:28:45 +01:00
|
|
|
offstate = "mesecons_extrawires:vertical_off",
|
|
|
|
rules = vertical_rules,
|
|
|
|
}}
|
2012-12-13 18:42:45 +01:00
|
|
|
})
|
|
|
|
|
2014-11-22 12:28:45 +01:00
|
|
|
-- Vertical wire top
|
|
|
|
mesecon.register_node("mesecons_extrawires:vertical_top", {
|
2012-12-13 18:42:45 +01:00
|
|
|
description = "Vertical mesecon",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
walkable = false,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
2013-12-18 21:14:03 +01:00
|
|
|
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
|
|
|
selection_box = top_box,
|
|
|
|
node_box = top_box,
|
2012-12-13 18:42:45 +01:00
|
|
|
is_vertical_conductor = true,
|
2014-11-22 12:28:45 +01:00
|
|
|
drop = "mesecons_extrawires:vertical_off",
|
|
|
|
after_place_node = vertical_update,
|
|
|
|
after_dig_node = vertical_update
|
|
|
|
},{
|
|
|
|
tiles = {"mesecons_wire_off.png"},
|
2012-12-13 18:42:45 +01:00
|
|
|
vertical_conductor_state = "off",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
onstate = "mesecons_extrawires:vertical_top_on",
|
2013-12-18 21:14:03 +01:00
|
|
|
rules = top_rules,
|
2014-11-22 12:28:45 +01:00
|
|
|
}}
|
|
|
|
},{
|
2014-11-22 11:37:47 +01:00
|
|
|
tiles = {"mesecons_wire_on.png"},
|
2012-12-13 18:42:45 +01:00
|
|
|
vertical_conductor_state = "on",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = mesecon.state.on,
|
2014-11-22 12:28:45 +01:00
|
|
|
offstate = "mesecons_extrawires:vertical_top_off",
|
|
|
|
rules = top_rules,
|
|
|
|
}}
|
2012-12-13 18:42:45 +01:00
|
|
|
})
|
|
|
|
|
2014-11-22 12:28:45 +01:00
|
|
|
-- Vertical wire bottom
|
|
|
|
mesecon.register_node("mesecons_extrawires:vertical_bottom", {
|
2012-12-13 18:42:45 +01:00
|
|
|
description = "Vertical mesecon",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
walkable = false,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
2012-12-15 18:45:51 +01:00
|
|
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
2013-12-18 21:14:03 +01:00
|
|
|
selection_box = bottom_box,
|
|
|
|
node_box = bottom_box,
|
2012-12-13 18:42:45 +01:00
|
|
|
is_vertical_conductor = true,
|
2014-11-22 12:28:45 +01:00
|
|
|
drop = "mesecons_extrawires:vertical_off",
|
|
|
|
after_place_node = vertical_update,
|
|
|
|
after_dig_node = vertical_update
|
|
|
|
},{
|
|
|
|
tiles = {"mesecons_wire_off.png"},
|
2012-12-13 18:42:45 +01:00
|
|
|
vertical_conductor_state = "off",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
onstate = "mesecons_extrawires:vertical_bottom_on",
|
2013-12-18 21:14:03 +01:00
|
|
|
rules = bottom_rules,
|
2014-11-22 12:28:45 +01:00
|
|
|
}}
|
|
|
|
},{
|
|
|
|
tiles = {"mesecons_wire_on.png"},
|
|
|
|
vertical_conductor_state = "on",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = mesecon.state.on,
|
|
|
|
offstate = "mesecons_extrawires:vertical_bottom_off",
|
|
|
|
rules = bottom_rules,
|
|
|
|
}}
|
2012-12-13 18:42:45 +01:00
|
|
|
})
|
2013-02-22 19:37:05 +01:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "mesecons_extrawires:vertical_off 3",
|
|
|
|
recipe = {
|
|
|
|
{"mesecons:wire_00000000_off"},
|
|
|
|
{"mesecons:wire_00000000_off"},
|
|
|
|
{"mesecons:wire_00000000_off"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "mesecons:wire_00000000_off",
|
|
|
|
recipe = {{"mesecons_extrawires:vertical_off"}}
|
|
|
|
})
|