Simple, yet effective.
If performance were a concern, which it probably isn’t in this case, if you knew that the matinee were going to take at least a minute, you could have an initial
_wait(50) and then do looping per frame
_wait calls after that. Though no need to do unneeded optimization.
Ideally coroutines are resumed with a callback from the engine though a poll can be really easy to write.
Take a look at the
InvokedBase class for some powerful methods. They are probably overkill with this example though I thought it would be a good time to point them out. You can get access to the current
InvokedMethod by using
this_code and then you can call the
InvokedBase methods on it.
At the script level (you can do similar things with coroutines written in C++) you would do something like this:
// Set something in motion that will take time
// Store this current invoked coroutine for later
// Suspend the coroutine
// Some other concurrently running code calls @invoked_coroutine.pending_decrement
// and this coroutine resumes.