From 10848f546e4ce68bcdc9b48a3b927613afa647ab Mon Sep 17 00:00:00 2001 From: Reuh Date: Fri, 29 Apr 2016 17:07:55 +0200 Subject: [PATCH] Fix TimeRegistry problems --- time.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/time.lua b/time.lua index 525a324..f22c420 100644 --- a/time.lua +++ b/time.lua @@ -47,12 +47,15 @@ local function newTimerRegistry() end end + local done = {} -- functions done running + local d = delayed for func, t in pairs(d) do local co = t.coroutine t.after = t.after - dt if t.after <= 0 then - d[func] = nil + d[func] = false -- niling here cause the next pair iteration to error + table.insert(done, func) if not co then co = coroutine.create(func) t.coroutine = co @@ -80,6 +83,12 @@ local function newTimerRegistry() end end end + + for _, func in ipairs(done) do + if not d[func] then + d[func] = nil + end + end end, --- Schedule a function to run.