Skip to content
Snippets Groups Projects
Commit 64d109b3 authored by Anthony Zhang's avatar Anthony Zhang
Browse files

`mesecon:updatenode()` was written to work only with conductors, though in...

`mesecon:updatenode()` was written to work only with conductors, though in several places it was used on recepters and effectors. This issue, reported by simion314, is fixed in this commit by explicitly checking for the type of mesecon node being updated.
parent 3bab7cb2
No related branches found
No related tags found
No related merge requests found
......@@ -236,7 +236,7 @@ end
function mesecon:connected_to_pw_src(pos, checked)
local c = 1
if checked == nil then checked = {} end
checked = checked or {}
while checked[c] ~= nil do --find out if node has already been checked (to prevent from endless loop)
if compare_pos(checked[c], pos) then
return false, checked
......@@ -246,16 +246,26 @@ function mesecon:connected_to_pw_src(pos, checked)
checked[c] = {x=pos.x, y=pos.y, z=pos.z} --add current node to checked
local node = minetest.env:get_node_or_nil(pos)
if node == nil then return false, checked end
if not mesecon:is_conductor(node.name) then return false, checked end
if node == nil then return false, checked end
if mesecon:is_receptor_node(node.name) then
return true, checked
end
if mesecon:is_receptor_node_off(node.name) then
return true, checked
end
if mesecon:is_powered_by_receptor(pos) then --return if conductor is powered
return true, checked
end
--Check if conductors around are connected
local connected
local rules = mesecon:conductor_get_rules(node)
if mesecon:is_conductor(node.name) then
rules = mesecon:conductor_get_rules(node)
elseif mesecon:is_effector(node.name) then
rules = mesecon:effector_get_input_rules(node)
else
return false, checked
end
for i, rule in ipairs(rules) do
local np = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment