mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Ability to remove minetest.after once set (#10103)
This commit is contained in:
parent
add68369a5
commit
34e3ede8ee
2 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue