0
0
Fork 0

Conductors no longer power themselves

This commit is contained in:
Wuzzy 2018-01-17 03:05:12 +01:00
parent 1522c875ae
commit 2cf6332b57
1 changed files with 8 additions and 3 deletions

View File

@ -516,7 +516,7 @@ function mesecon.rules_link_rule_all_inverted(input, rule)
return rules return rules
end end
function mesecon.is_powered(pos, rule, depth, sourcepos) function mesecon.is_powered(pos, rule, depth, sourcepos, home_pos)
if depth == nil then depth = 0 end if depth == nil then depth = 0 end
if depth > 1 then if depth > 1 then
return false return false
@ -526,6 +526,9 @@ function mesecon.is_powered(pos, rule, depth, sourcepos)
if not rules then if not rules then
return false return false
end end
if not home_pos then
home_pos = pos
end
-- List of nodes that send out power to pos -- List of nodes that send out power to pos
if sourcepos == nil then if sourcepos == nil then
@ -538,9 +541,11 @@ function mesecon.is_powered(pos, rule, depth, sourcepos)
local nn = mesecon.get_node_force(np) local nn = mesecon.get_node_force(np)
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname)) if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
or mesecon.is_receptor_on (nn.name)) then or mesecon.is_receptor_on (nn.name)) then
table.insert(sourcepos, np) if not vector.equals(home_pos, np) then
table.insert(sourcepos, np)
end
elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then elseif depth == 0 and minetest.get_item_group(nn.name, "opaque") == 1 then
local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos) local more_sourcepos = mesecon.is_powered(np, nil, depth + 1, sourcepos, home_pos)
mesecon.mergetable(sourcepos, more_sourcepos) mesecon.mergetable(sourcepos, more_sourcepos)
end end
end end