3 local last = core.get_us_time() / 1000000
5 core.register_globalstep(function(dtime)
6 local new = core.get_us_time() / 1000000
8 time = time + (new - last)
10 -- Overflow, we may lose a little bit of time here but
11 -- only 1 tick max, potentially running timers slightly
21 -- Iterate backwards so that we miss any new timers added by
22 -- a timer callback, and so that we don't skip the next timer
23 -- in the list if we remove one.
24 for i = #jobs, 1, -1 do
26 if time >= job.expire then
27 core.set_last_run_mod(job.mod_origin)
28 job.func(unpack(job.arg))
34 function core.after(after, func, ...)
35 assert(tonumber(after) and type(func) == "function",
36 "Invalid core.after invocation")
39 expire = time + after,
41 mod_origin = core.get_last_run_mod()