diff options
author | Jeija <jeija@mesecons.net> | 2014-01-11 16:46:27 +0100 |
---|---|---|
committer | Jeija <jeija@mesecons.net> | 2014-01-11 16:46:27 +0100 |
commit | 1083539e9b82c729687f012e741614d1fc216757 (patch) | |
tree | 19daf44da46c8c9227952e550082c401b5866f85 /mesecons/actionqueue.lua | |
parent | 6afded8284e42c8b976d8685f537d8d54264277a (diff) | |
download | mesecons-1083539e9b82c729687f012e741614d1fc216757.tar mesecons-1083539e9b82c729687f012e741614d1fc216757.tar.gz mesecons-1083539e9b82c729687f012e741614d1fc216757.tar.bz2 mesecons-1083539e9b82c729687f012e741614d1fc216757.tar.xz mesecons-1083539e9b82c729687f012e741614d1fc216757.zip |
Resume turnon/off calls as soon as area is loaded in case turnon/off calls end in unloaded territory
Diffstat (limited to 'mesecons/actionqueue.lua')
-rw-r--r-- | mesecons/actionqueue.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mesecons/actionqueue.lua b/mesecons/actionqueue.lua index 1c02b46..66e9fd7 100644 --- a/mesecons/actionqueue.lua +++ b/mesecons/actionqueue.lua @@ -20,24 +20,28 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior owcheck=(overwritecheck and mesecon:tablecopy(overwritecheck)) or nil, priority=priority} - --print(dump(action)) -- if not using the queue, (MESECONS_GLOBALSTEP off), just execute the function an we're done if not MESECONS_GLOBALSTEP then mesecon.queue:execute(action) return end + local toremove = nil -- Otherwise, add the action to the queue if overwritecheck then -- check if old action has to be overwritten / removed: for i, ac in ipairs(mesecon.queue.actions) do if(mesecon:cmpPos(pos, ac.pos) and mesecon:cmpAny(overwritecheck, ac.owcheck)) then - table.remove(mesecon.queue.actions, i) + toremove = i break end end end + if (toremove ~= nil) then + table.remove(mesecon.queue.actions, i) + end + table.insert(mesecon.queue.actions, action) end |