-
Notifications
You must be signed in to change notification settings - Fork 0
timer functions
Registers a function to be called after interval
milliseconds. The function will be called in the main Lua thread. If additional arguments are provided, they will be passed to the function.
Registers a function to be called after interval
server ticks. The function will be called in the main Lua thread. If additional arguments are provided, they will be passed to the function.
Calls func(...)
but every count
(default 100000) Lua VM instructions yields function(cont)tick(cont, 1)end
from the Lua thread. If this is called inside async
, it will register a function that resumes the coroutine. This creates the effect of running the code in parallel with the main thread; if the code takes too long to execute, it will be paused and scheduled on the next tick.
Non-Lua code cannot be interrupted this way, but most native functions in YALP can handle calling functions that may yield.
Like parallel
, but it yields regfunc
.
Performs a blocking sleep on the current system thread for the given number of milliseconds. The sleep is active, i.e. it contains a loop that checks if the duration has elapsed or not. However, the loop is actually performed in Lua code, so it can be interrupted by hooks or paused via parallel
.
This function should only be used as a substitute for CPU-intensive code, to test async
and parallel
. Use wait
to pause the script asynchronously.
Analogous to coroutine.yield(timer.ms, ms, ...)
. Usually, this function should be called inside async
, which handles the yield and registers the continuation, making the wait asynchronous.
Analogous to coroutine.yield(timer.tick, ticks, ...)
with semantics similar to wait
.