https://forum.cockos.com/showthread.php?t=223271
Didn't know about this thread when I posted this, but a way to wait until a MainOnCommand action finishes before continuing the rest of the script would be super useful. Would solve all kinds of asynchronous code issues