Redstone: Propagate turnoff through opaque blocks

This commit is contained in:
Wuzzy 2018-01-20 19:55:25 +01:00
parent 33d978de06
commit f4657f79f5
1 changed files with 15 additions and 2 deletions

View File

@ -446,7 +446,7 @@ function mesecon.turnoff(pos, link)
local node = mesecon.get_node_force(f.pos) local node = mesecon.get_node_force(f.pos)
if not node then if not node then
-- Area does not exist; do nothing -- No-op
elseif mesecon.is_conductor_on(node, f.link) then elseif mesecon.is_conductor_on(node, f.link) then
local rules = mesecon.conductor_get_rules(node) local rules = mesecon.conductor_get_rules(node)
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
@ -476,8 +476,21 @@ function mesecon.turnoff(pos, link)
depth = depth depth = depth
}) })
end end
if node and f.link.spread and minetest.get_item_group(node.name, "opaque") == 1 then if node and f.link.spread and minetest.get_item_group(node.name, "opaque") == 1 then
-- TODO: Call turnoff on neighbors -- Call turnoff on neighbors
-- Warning: A LOT of nodes need to be looked at for this to work
for _, r in ipairs(mesecon.rule2meta(f.link, mesecon.rules.mcl_alldirs_spread)) do
local np = vector.add(f.pos, r)
if mesecon.is_receptor_on(mesecon.get_node_force(np).name) then
return false
end
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
local nlink = table.copy(l)
nlink.spread = false
table.insert(frontiers, {pos = np, link = nlink})
end
end
end end
depth = depth + 1 depth = depth + 1