Fix #182, bug when placing wire crossings next to a powered source

In case this fix creates new bugs, please report them.
This commit is contained in:
Jeija
2014-11-21 22:04:39 +01:00
parent dcf1f799c5
commit 1b9f1b8c13
2 changed files with 18 additions and 8 deletions

View File

@ -597,14 +597,18 @@ function mesecon:is_powered(pos, rule)
local rules = mesecon:get_any_inputrules(node)
if not rules then return false end
-- List of nodes that send out power to pos
local sourcepos = {}
if not rule then
for _, rule in ipairs(mesecon:flattenrules(rules)) do
local rulenames = mesecon:rules_link_rule_all_inverted(pos, rule)
for _, rname in ipairs(rulenames) do
local np = mesecon:addPosRule(pos, rname)
local nn = minetest.get_node(np)
if (mesecon:is_conductor_on (nn, mesecon:invertRule(rname)) or mesecon:is_receptor_on (nn.name)) then
return true
if (mesecon:is_conductor_on (nn, mesecon:invertRule(rname))
or mesecon:is_receptor_on (nn.name)) then
table.insert(sourcepos, np)
end
end
end
@ -614,12 +618,14 @@ function mesecon:is_powered(pos, rule)
local np = mesecon:addPosRule(pos, rname)
local nn = minetest.get_node(np)
if (mesecon:is_conductor_on (nn, mesecon:invertRule(rname)) or mesecon:is_receptor_on (nn.name)) then
return true
sourcepos.insert(np)
end
end
end
return false
-- Return FALSE if not powered, return list of sources if is powered
if (#sourcepos == 0) then return false
else return sourcepos end
end
--Rules rotation Functions: