From 64d109b31b2141423773f1a85240700e79b902ea Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sat, 1 Dec 2012 18:34:05 -0500 Subject: [PATCH] `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. --- mesecons/internal.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index ce43ce5..e45fe4e 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -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 = {}