Cute but pkInterpretSource() doesn't have any throttling, like the amount of instructions/nodes to execute before suspending, this would be very useful in games. You could limit NPC's ai to 50 instructions or so so that it doesn't cause rendering lag and the ai script would be run in multiple frames until it finishes.
I guess the fiber/coroutine support would be a better solution to this problem? If this works like I think it should work, the code can decide itself when it is a good time to yield control back to the environment instead of freezing execution in a random location until the next frame. For instance when evaluating NPC AIs it may be important that an NPC isn't left dangling in a random state at the end of a frame, but…
if x
If "x" and "sin(5)" was evaluated but not "cos(20)" then it should just remember VM state and continue next time. I did this in JS and it worked great for distributing NPC load between frames (https://twitter.com/dusan_halicky/status/1173924435923001344) and it didn't required any understanding of the code (I didn't need to carefully check when I need to stop execution), just VM snapshot and continue next frame.