after: add nil support

This commit is contained in:
Lars Mueller 2022-01-19 16:15:43 +01:00
parent d709a7e001
commit 5d3c011f79

@ -1,6 +1,6 @@
-- Localize globals -- Localize globals
local Settings, assert, minetest, modlib, next, pairs, ipairs, string, setmetatable, table, type, unpack local Settings, assert, minetest, modlib, next, pairs, ipairs, string, setmetatable, select, table, type, unpack
= Settings, assert, minetest, modlib, next, pairs, ipairs, string, setmetatable, table, type, unpack = Settings, assert, minetest, modlib, next, pairs, ipairs, string, setmetatable, select, table, type, unpack
-- Set environment -- Set environment
local _ENV = ... local _ENV = ...
@ -29,6 +29,7 @@ function after(seconds, func, ...)
local job = setmetatable({ local job = setmetatable({
time = time + seconds, time = time + seconds,
func = func, func = func,
["#"] = select("#", ...),
... ...
}, job_metatable) }, job_metatable)
jobs:push(job) jobs:push(job)
@ -39,7 +40,7 @@ minetest.register_globalstep(function(dtime)
local job = jobs[1] local job = jobs[1]
while job and job.time <= time do while job and job.time <= time do
if not job.cancelled then if not job.cancelled then
job.func(unpack(job)) job.func(unpack(job, 1, job["#"]))
end end
jobs:pop() jobs:pop()
job = jobs[1] job = jobs[1]