May 2017
Intermediate to advanced
416 pages
21h 33m
English
To get the current status of a coroutine, we can use the function coroutine.status. The function can return one of the following values:
|
running |
Coroutine is executing |
|
dead |
Coroutine has finished running |
|
suspended |
Coroutine is waiting to be executed |
For example:
local nt=coroutine.create(function() print(string.format("I’m aliveee! The status of the coroutine is:%s", coroutine.status(coroutine.running()))) end) coroutine.resume(nt) print("Now I'm "..coroutine.status(nt))
The output will be:
I’m aliveee! The status of the coroutine is:running Now I'm dead
Read now
Unlock full access