diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-03-11 03:06:07 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-03-11 11:10:42 +0100 |
commit | f066f988ac60571304b2301c57d5fbbf5da332cf (patch) | |
tree | 88efcc0479269bb726d02611edebefa8b7f14b2d /scripts/lua | |
parent | 01977a101d839107d8c28ca31f885f67e660dd68 (diff) | |
download | manaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.tar.gz manaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.tar.bz2 manaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.tar.xz manaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.zip |
Simplified check_schedule a bit
Diffstat (limited to 'scripts/lua')
-rw-r--r-- | scripts/lua/libmana.lua | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index 62c089f8..f9f28575 100644 --- a/scripts/lua/libmana.lua +++ b/scripts/lua/libmana.lua @@ -341,23 +341,18 @@ end -- checks for jobs which have to be executed, executes them and reschedules -- them when they are repeated jobs. function check_schedule() - if #scheduler_jobs==0 then return end - local current_time = os.time() - while current_time > scheduler_jobs[#scheduler_jobs][0] do + + while #scheduler_jobs~=0 and current_time > scheduler_jobs[#scheduler_jobs][0] do -- retreive the job and remove it from the schedule job = scheduler_jobs[#scheduler_jobs] - table.remove(scheduler_jobs) - -- reschedule the job when it is a repeated job - if job[2] then - schedule_every(job[2], job[1]) - end - -- execute the job - job[1]() - - -- avoid looping on an empty table - if #scheduler_jobs==0 then return end - + table.remove(scheduler_jobs) + -- reschedule the job when it is a repeated job + if job[2] then + schedule_every(job[2], job[1]) + end + -- execute the job + job[1]() end end |