Issue with updatescript
So I just found out the hard way that, if a call to the updatescript is in progress, it won't be called again. Normally this isn't an issue, but in my particular case it's a big problem.
You see, in the Specs engine, I've implemented a custom threader to allow simultaneous operations (e.g. asynchronous tweens, or have a separate thread for battle menus while the battle engine runs in the background, that kind of thing). If you need to wait for a certain thread to complete without affecting other asynchronous stuff, you call Threads.wait(); which enters an update/render loop until the specified thread terminates. Here's the problem, though: MapEngine() runs its own game loop. Which means, in order for the threader to still work on the field, I have to add calls to Threads.updateAll and Threads.renderAll to the update and render scripts respectively. This is fine and works 95% of the time--right up until somebody calls Threads.wait(). Since that almost always happens in a thread's update function, this blocks the updatescript itself while the threader runs its wait loop--which itself includes a call to UpdateMapEngine()! This in turn causes the entire threader to deadlock.
There's a couple workarounds I've considered already. One was to forego the update/renderscripts entirely and just add a thread that updates the map engine itself. While this would keep the map engine running during battles, menus, etc, the threader would be unavailable on the field. This is the cleanest method, but the lack of threading on the field will likely be a deal breaker.
Another method is to call UpdateMapEngine AND Threads.updateAll in the wait loop. Unfortunately, this causes double updates when the updatescript doesn't happen to be blocked--for example, when Threads.wait is called from a persist.js map script.
Then you have the last method, the one I'm using now, which doesn't call UpdateMapEngine at all, only Threads.updateAll. The problem here should be obvious: The map engine is frozen in place until control returns to the original MapEngine game loop (e.g. when the battle is over).
None of these solutions is really ideal for what I'm going for with Spectacles, so I'm going to ask, is there a better method to solve this problem than the three fixes above?