mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Ability to remove minetest.after once set (#10103)
This commit is contained in:
parent
add68369a5
commit
34e3ede8ee
@ -31,11 +31,13 @@ function core.after(after, func, ...)
|
|||||||
assert(tonumber(after) and type(func) == "function",
|
assert(tonumber(after) and type(func) == "function",
|
||||||
"Invalid minetest.after invocation")
|
"Invalid minetest.after invocation")
|
||||||
local expire = time + after
|
local expire = time + after
|
||||||
jobs[#jobs + 1] = {
|
local new_job = {
|
||||||
func = func,
|
func = func,
|
||||||
expire = expire,
|
expire = expire,
|
||||||
arg = {...},
|
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)
|
time_next = math.min(time_next, expire)
|
||||||
|
return { cancel = function() new_job.func = function() end end }
|
||||||
end
|
end
|
||||||
|
@ -5336,10 +5336,13 @@ Sounds
|
|||||||
Timing
|
Timing
|
||||||
------
|
------
|
||||||
|
|
||||||
* `minetest.after(time, func, ...)`
|
* `minetest.after(time, func, ...)` : returns job table to use as below.
|
||||||
* Call the function `func` after `time` seconds, may be fractional
|
* Call the function `func` after `time` seconds, may be fractional
|
||||||
* Optional: Variable number of arguments that are passed to `func`
|
* Optional: Variable number of arguments that are passed to `func`
|
||||||
|
|
||||||
|
* `job:cancel()`
|
||||||
|
* Cancels the job function from being called
|
||||||
|
|
||||||
Server
|
Server
|
||||||
------
|
------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user