summaryrefslogtreecommitdiff
path: root/mesecons_extrawires
diff options
context:
space:
mode:
Diffstat (limited to 'mesecons_extrawires')
-rw-r--r--mesecons_extrawires/corner.lua2
-rw-r--r--mesecons_extrawires/mesewire.lua7
-rw-r--r--mesecons_extrawires/tjunction.lua2
-rw-r--r--mesecons_extrawires/vertical.lua148
4 files changed, 62 insertions, 97 deletions
diff --git a/mesecons_extrawires/corner.lua b/mesecons_extrawires/corner.lua
index d7f7a02..003275a 100644
--- a/mesecons_extrawires/corner.lua
+++ b/mesecons_extrawires/corner.lua
@@ -15,7 +15,7 @@ local corner_get_rules = function (node)
{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
- rules = mesecon:rotate_rules_left(rules)
+ rules = mesecon.rotate_rules_left(rules)
end
return rules
diff --git a/mesecons_extrawires/mesewire.lua b/mesecons_extrawires/mesewire.lua
index cbb882e..150178c 100644
--- a/mesecons_extrawires/mesewire.lua
+++ b/mesecons_extrawires/mesewire.lua
@@ -8,12 +8,7 @@ local mesewire_rules =
{x = 0, y = 0, z =-1},
}
-minetest.register_node(":default:mese", {
- description = "Mese Block",
- tiles = {minetest.registered_nodes["default:mese"].tiles[1]},
- is_ground_content = true,
- groups = {cracky=1},
- sounds = default.node_sound_stone_defaults(),
+minetest.override_item("default:mese", {
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:mese_powered",
diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua
index c5f36a2..680dc99 100644
--- a/mesecons_extrawires/tjunction.lua
+++ b/mesecons_extrawires/tjunction.lua
@@ -16,7 +16,7 @@ local tjunction_get_rules = function (node)
{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
- rules = mesecon:rotate_rules_left(rules)
+ rules = mesecon.rotate_rules_left(rules)
end
return rules
diff --git a/mesecons_extrawires/vertical.lua b/mesecons_extrawires/vertical.lua
index 16de55e..cac2ae2 100644
--- a/mesecons_extrawires/vertical.lua
+++ b/mesecons_extrawires/vertical.lua
@@ -18,7 +18,7 @@ local bottom_box = {
local vertical_rules = {
{x=0, y=1, z=0},
- {x=0, y=-1, z=0},
+ {x=0, y=-1, z=0}
}
local top_rules = {
@@ -26,7 +26,7 @@ local top_rules = {
{x=-1,y=0, z=0},
{x=0,y=0, z=1},
{x=0,y=0, z=-1},
- {x=0,y=-1, z=0},
+ {x=0,y=-1, z=0}
}
local bottom_rules = {
@@ -35,107 +35,79 @@ local bottom_rules = {
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
{x=0, y=1, z=0},
+ {x=0, y=2, z=0} -- receive power from pressure plate / detector / ... 2 nodes above
}
local vertical_updatepos = function (pos)
local node = minetest.get_node(pos)
- if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].is_vertical_conductor then
- local node_above = minetest.get_node(mesecon:addPosRule(pos, vertical_rules[1]))
- local node_below = minetest.get_node(mesecon:addPosRule(pos, vertical_rules[2]))
+ if minetest.registered_nodes[node.name]
+ and minetest.registered_nodes[node.name].is_vertical_conductor then
+ local node_above = minetest.get_node(mesecon.addPosRule(pos, vertical_rules[1]))
+ local node_below = minetest.get_node(mesecon.addPosRule(pos, vertical_rules[2]))
local namestate = minetest.registered_nodes[node.name].vertical_conductor_state
- 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
+ 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
+ local basename = "mesecons_extrawires:vertical_"
if above and below then -- above and below: vertical mesecon
- minetest.add_node(pos, {name = "mesecons_extrawires:vertical_" .. namestate})
+ minetest.add_node(pos, {name = basename .. namestate})
elseif above and not below then -- above only: bottom
- minetest.add_node(pos, {name = "mesecons_extrawires:vertical_bottom_" .. namestate})
+ minetest.add_node(pos, {name = basename .. "bottom_" .. namestate})
elseif not above and below then -- below only: top
- minetest.add_node(pos, {name = "mesecons_extrawires:vertical_top_" .. namestate})
- else -- no vertical wire above, no vertical wire below: use default wire
- minetest.add_node(pos, {name = "mesecons_extrawires:vertical_" .. namestate})
+ 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})
end
+ mesecon.update_autoconnect(pos)
end
end
local vertical_update = function (pos, node)
vertical_updatepos(pos) -- this one
- vertical_updatepos(mesecon:addPosRule(pos, vertical_rules[1])) -- above
- vertical_updatepos(mesecon:addPosRule(pos, vertical_rules[2])) -- below
+ vertical_updatepos(mesecon.addPosRule(pos, vertical_rules[1])) -- above
+ vertical_updatepos(mesecon.addPosRule(pos, vertical_rules[2])) -- below
end
-- Vertical wire
-minetest.register_node("mesecons_extrawires:vertical_on", {
+mesecon.register_node("mesecons_extrawires:vertical", {
description = "Vertical mesecon",
drawtype = "nodebox",
- tiles = {"wires_vertical_on.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
- groups = {dig_immediate=3, not_in_creative_inventory=1},
selection_box = vertical_box,
node_box = vertical_box,
is_vertical_conductor = true,
- vertical_conductor_state = "on",
- mesecons = {conductor = {
- state = mesecon.state.on,
- offstate = "mesecons_extrawires:vertical_off",
- rules = vertical_rules,
- }},
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
- after_dig_node = vertical_update,
-})
-
-minetest.register_node("mesecons_extrawires:vertical_off", {
- description = "Vertical mesecon",
- drawtype = "nodebox",
- tiles = {"wires_vertical_off.png"},
- walkable = false,
- paramtype = "light",
- sunlight_propagates = true,
+ after_dig_node = vertical_update
+},{
+ tiles = {"mesecons_wire_off.png"},
groups = {dig_immediate=3},
- selection_box = vertical_box,
- node_box = vertical_box,
- is_vertical_conductor = true,
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_on",
rules = vertical_rules,
- }},
- after_place_node = vertical_update,
- after_dig_node = vertical_update,
-})
-
--- Vertical wire top
-minetest.register_node("mesecons_extrawires:vertical_top_on", {
- description = "Vertical mesecon",
- drawtype = "nodebox",
- tiles = {"wires_full_on.png","wires_full_on.png","wires_vertical_on.png"},
- walkable = false,
- paramtype = "light",
- sunlight_propagates = true,
+ }}
+},{
+ tiles = {"mesecons_wire_on.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
- selection_box = top_box,
- node_box = top_box,
- is_vertical_conductor = true,
vertical_conductor_state = "on",
mesecons = {conductor = {
state = mesecon.state.on,
- offstate = "mesecons_extrawires:vertical_top_off",
- rules = top_rules,
- }},
- drop = "mesecons_extrawires:vertical_off",
- after_place_node = vertical_update,
- after_dig_node = vertical_update,
+ offstate = "mesecons_extrawires:vertical_off",
+ rules = vertical_rules,
+ }}
})
-minetest.register_node("mesecons_extrawires:vertical_top_off", {
+-- Vertical wire top
+mesecon.register_node("mesecons_extrawires:vertical_top", {
description = "Vertical mesecon",
drawtype = "nodebox",
- tiles = {"wires_full_off.png","wires_full_off.png","wires_vertical_off.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
@@ -143,43 +115,31 @@ minetest.register_node("mesecons_extrawires:vertical_top_off", {
selection_box = top_box,
node_box = top_box,
is_vertical_conductor = true,
+ drop = "mesecons_extrawires:vertical_off",
+ after_place_node = vertical_update,
+ after_dig_node = vertical_update
+},{
+ tiles = {"mesecons_wire_off.png"},
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_top_on",
rules = top_rules,
- }},
- drop = "mesecons_extrawires:vertical_off",
- after_place_node = vertical_update,
- after_dig_node = vertical_update,
-})
-
--- Vertical wire bottom
-minetest.register_node("mesecons_extrawires:vertical_bottom_on", {
- description = "Vertical mesecon",
- drawtype = "nodebox",
- tiles = {"wires_full_on.png","wires_full_on.png","wires_vertical_on.png"},
- walkable = false,
- paramtype = "light",
- sunlight_propagates = true,
+ }}
+},{
+ tiles = {"mesecons_wire_on.png"},
vertical_conductor_state = "on",
- groups = {dig_immediate = 3, not_in_creative_inventory = 1},
- selection_box = bottom_box,
- node_box = bottom_box,
mesecons = {conductor = {
state = mesecon.state.on,
- offstate = "mesecons_extrawires:vertical_bottom_off",
- rules = bottom_rules,
- }},
- drop = "mesecons_extrawires:vertical_off",
- after_place_node = vertical_update,
- after_dig_node = vertical_update,
+ offstate = "mesecons_extrawires:vertical_top_off",
+ rules = top_rules,
+ }}
})
-minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
+-- Vertical wire bottom
+mesecon.register_node("mesecons_extrawires:vertical_bottom", {
description = "Vertical mesecon",
drawtype = "nodebox",
- tiles = {"wires_full_off.png","wires_full_off.png","wires_vertical_off.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
@@ -187,15 +147,25 @@ minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
selection_box = bottom_box,
node_box = bottom_box,
is_vertical_conductor = true,
+ drop = "mesecons_extrawires:vertical_off",
+ after_place_node = vertical_update,
+ after_dig_node = vertical_update
+},{
+ tiles = {"mesecons_wire_off.png"},
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_bottom_on",
rules = bottom_rules,
- }},
- drop = "mesecons_extrawires:vertical_off",
- after_place_node = vertical_update,
- after_dig_node = vertical_update,
+ }}
+},{
+ tiles = {"mesecons_wire_on.png"},
+ vertical_conductor_state = "on",
+ mesecons = {conductor = {
+ state = mesecon.state.on,
+ offstate = "mesecons_extrawires:vertical_bottom_off",
+ rules = bottom_rules,
+ }}
})
minetest.register_craft({