diff options
author | Jeija <jeija@mesecons.net> | 2014-01-05 19:55:45 +0100 |
---|---|---|
committer | Jeija <jeija@mesecons.net> | 2014-01-05 19:55:45 +0100 |
commit | 7d8fd7a8df5252cdb5b1d4ac95aeb9f1f6eaaaa8 (patch) | |
tree | c35f9b8554f4a00e645bd0bd16a4ba8fdfd8c12c | |
parent | 39361fb7192e8746927a3bd080a24bd0a89fa3ee (diff) |
Fix issue #135origin/patch_#135
-rw-r--r-- | mesecons/internal.lua | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mesecons/internal.lua b/mesecons/internal.lua index cb77f5d..1daf1c2 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -275,20 +275,15 @@ end minetest.register_globalstep(execute_actions) function add_action(pos, action, rname) - for _,i in ipairs(mesecon.to_update) do - if i.pos.x == pos.x and i.pos.y == pos.y and i.pos.z == pos.z and i.rname.x == rname.x and i.rname.y == rname.y and i.rname.z == rname.z then - if (i.action == "on" and action == "on") or (i.action == "off" and action == "off") then - --nothing - elseif i.action == "coff" and action == "on" then i.action = "on" - elseif i.action == "con" and action == "off" then i.action = "off" - else - if action == "on" or action == "con" then i.action = "con" end - if action == "off" or action == "coff" then i.action = "coff" end - end - break + for i, update in ipairs(mesecon.to_update) do + -- check if action for this node already exist, if so correct it: + if mesecon:cmpPos(pos, update.pos) and mesecon:cmpPos(update.rname, rname) then + mesecon.to_update[i].action = action + return -- action added (as correction), so return now end end - mesecon.to_update[#mesecon.to_update+1] = {pos = pos, action = action, rname = rname} + + table.insert(mesecon.to_update, {pos = pos, action = action, rname = rname}) end --Rules |