xhookLua
Game

task

Per-frame coroutine scheduler in wall-clock seconds; tasks die with their script.

Functions

task.spawn

task.spawn(fn)
NameTypeDescription
fnfunctionCoroutine body, no arguments.

Runs fn as a task, starting next frame.

An error is logged and ends only that task.

task.defer

task.defer(fn)
NameType
fnfunction

Same as task.spawn.

task.wait

task.wait([seconds = 0])
NameTypeDescription
secondsoptionalnumber0 or less: next frame. Default 0.

Suspends the current task for at least seconds.

Raises outside task.spawn, defer, delay or interval.

task.delay

task.delay(seconds, fn) -> cancel
NameTypeDescription
secondsnumber
fnfunctionCalled once.

Runs fn once after a delay.

Returns cancel function

task.interval

task.interval(seconds, fn) -> cancel
NameTypeDescription
secondsnumber0 calls fn every frame.
fnfunction

Calls fn every interval, first after one interval.

Returns cancel function

  • Timed from each call's end, so a slow fn drifts.
  • An error in fn ends the timer.
task ยท Lua API ยท xhook