Resume turnon/off calls as soon as area is loaded in case turnon/off calls end in unloaded territory

This commit is contained in:
Jeija
2014-01-11 16:46:27 +01:00
parent 6afded8284
commit 1083539e9b
2 changed files with 44 additions and 8 deletions

View File

@ -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