3 local time_next = math.huge
5 core.register_globalstep(function(dtime)
8 if time < time_next then
14 -- Iterate backwards so that we miss any new timers added by
16 for i = #jobs, 1, -1 do
18 if time >= job.expire then
19 core.set_last_run_mod(job.mod_origin)
20 job.func(unpack(job.arg))
22 jobs[i] = jobs[jobs_l]
24 elseif job.expire < time_next then
25 time_next = job.expire
30 function core.after(after, func, ...)
31 assert(tonumber(after) and type(func) == "function",
32 "Invalid minetest.after invocation")
33 local expire = time + after
38 mod_origin = core.get_last_run_mod(),
41 jobs[#jobs + 1] = new_job
42 time_next = math.min(time_next, expire)
46 new_job.func = function() end