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
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 > 1 then
return false
@ -526,6 +526,9 @@ function mesecon.is_powered(pos, rule, depth, sourcepos)
if not rules then
return false
end
if not home_pos then
home_pos = pos
end
-- List of nodes that send out power to pos
if sourcepos == nil then
@ -538,9 +541,11 @@ function mesecon.is_powered(pos, rule, depth, sourcepos)
local nn = mesecon.get_node_force(np)
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
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
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)
end
end