Skip to content
Permalink
Browse files

Fix vertical wires not updating power when adding to / removing from …

…a vertical line

Call mesecon.on_dignode / mesecon.on_placenode to take care of that.
  • Loading branch information...
Jeija committed Feb 15, 2016
1 parent fe9c687 commit 80f72b26218b2a647dbcb4e413efccfcb6e74347
Showing with 11 additions and 13 deletions.
  1. +11 −13 mesecons_extrawires/vertical.lua
@@ -44,24 +44,28 @@ local vertical_updatepos = function (pos)
and minetest.registered_nodes[node.name].is_vertical_conductor then
local node_above = minetest.get_node(vector.add(pos, vertical_rules[1]))
local node_below = minetest.get_node(vector.add(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 basename = "mesecons_extrawires:vertical_"
mesecon.on_dignode(pos, node)

-- Always place offstate conductor and let mesecon.on_placenode take care
local newname = "mesecons_extrawires:vertical_"
if above and below then -- above and below: vertical mesecon
minetest.set_node(pos, {name = basename .. namestate})
newname = newname .. "off"
elseif above and not below then -- above only: bottom
minetest.set_node(pos, {name = basename .. "bottom_" .. namestate})
newname = newname .. "bottom_off"
elseif not above and below then -- below only: top
minetest.set_node(pos, {name = basename .. "top_" .. namestate})
newname = newname .. "top_off"
else -- no vertical wire above, no vertical wire below: use bottom
minetest.set_node(pos, {name = basename .. "bottom_" .. namestate})
newname = newname .. "bottom_off"
end
mesecon.update_autoconnect(pos)

minetest.set_node(pos, {name = newname})
mesecon.on_placenode(pos, {name = newname})
end
end

@@ -87,7 +91,6 @@ mesecon.register_node("mesecons_extrawires:vertical", {
},{
tiles = {"mesecons_wire_off.png"},
groups = {dig_immediate=3},
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_on",
@@ -96,7 +99,6 @@ mesecon.register_node("mesecons_extrawires:vertical", {
},{
tiles = {"mesecons_wire_on.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
vertical_conductor_state = "on",
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:vertical_off",
@@ -120,15 +122,13 @@ mesecon.register_node("mesecons_extrawires:vertical_top", {
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,
}}
},{
tiles = {"mesecons_wire_on.png"},
vertical_conductor_state = "on",
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:vertical_top_off",
@@ -152,15 +152,13 @@ mesecon.register_node("mesecons_extrawires:vertical_bottom", {
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,
}}
},{
tiles = {"mesecons_wire_on.png"},
vertical_conductor_state = "on",
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:vertical_bottom_off",

0 comments on commit 80f72b2

Please sign in to comment.
You can’t perform that action at this time.