Function
isTask
Checks whether a value is a task returned by async.
Syntax
bool isTask(var value)Arguments
valuevar- Any value.
Returns
true for a task.
Example
local task = async(function() sleep(100) end)
print(isTask(task), isTask({})) -- true false
See also
asyncRuns a function as a task (coroutine). The code in the task runs immediately until its first wait (sleep,await,waitForEvent). Then it yields and the server and the game keep running. When the wait is over, the task continues from where it stopped. This lets you write steps spread over time (a countdown, a database query, an HTTP response, waiting for a player) one after another, without nested callbacks and timers.getTaskStatusReturns the state of a task fromasync:"running"(waiting or working),"done"(finished) or"failed"(error). After the state it returns the values returned by the task function or, for"failed", the error message.