diff options
author | Anthony Zhang <azhang9@gmail.com> | 2012-12-01 18:34:05 -0500 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2012-12-01 18:34:05 -0500 |
commit | 64d109b31b2141423773f1a85240700e79b902ea (patch) | |
tree | 754d0b5e8263a7cc306d6d615bd82f1a91642ccf | |
parent | 3bab7cb2524d287ef32c5a3924560fc194e7b22d (diff) |
`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.
-rw-r--r-- | mesecons/internal.lua | 20 |
1 files 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 = {} |