Log In  

@zep There is a mistake in the PICO-8 manual.

6.14 Additional Lua Features > Coroutines > costatus(c)

Return the status of coroutine C as a string:
  "running"
  "suspended"
  "dead"

The status "normal" is missing.

When coroutine A calls coroutine B, and you check the status of A in B, you will get "normal".

P#131581 2023-07-03 06:38 ( Edited 2024-01-17 02:11)

1

oh wow, I had no idea this "normal" thing existed!

for reference, the relevant section from the Lua 5.2 manual:

coroutine.status (co)

Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error.

...and a code example which outputs the "normal" status:

function cnorm()
    coresume(b)
end
function cprint()
    print(costatus(a))
end
a=cocreate(cnorm)
b=cocreate(cprint)
coresume(a)

P#131591 2023-07-03 15:16

[Please log in to post a comment]