Ability to remove minetest.after once set (#10103)

This commit is contained in:
tenplus1 2020-09-23 18:11:56 +01:00 committed by Nils Dagsson Moskopp
parent fb5c84855d
commit 03cb42f725
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 4 additions and 2 deletions

View File

@ -31,11 +31,13 @@ function core.after(after, func, ...)
assert(tonumber(after) and type(func) == "function",
"Invalid minetest.after invocation")
local expire = time + after
jobs[#jobs + 1] = {
local new_job = {
func = func,
expire = expire,
arg = {...},
mod_origin = core.get_last_run_mod()
mod_origin = core.get_last_run_mod(),
}
jobs[#jobs + 1] = new_job
time_next = math.min(time_next, expire)
return { cancel = function() new_job.func = function() end end }
end