JujuAdams/Coroutines

Add RESTART and PAUSE commands

JujuAdams opened this issue · 1 comments

At the moment calling .Restart(), .Pause(), or .Cancel() from within the target coroutine causes unexpected behaviour. Due to the way the coroutine VM works, coroutine execution state is only considered at the end of a code block (at a macro). This means exhibited behaviour is

CO_BEGIN
    show_debug_message("This appears");
    Restart();
    show_debug_message("And this does too");
CO_END

In order to work around this problem, two things need to be done:

  1. Prevent .Restart(), .Pause(), or .Cancel() being called from within the target coroutine (and should instead throw an error)
  2. Implement RESTART and PAUSE commands to create a breakpoint within the coroutine

Implemented for v1.2