EDIT: @richard took this idea and went further building an awesome new extension: https://github.com/riknoll/arcade-story
Expect a post about this sometime eventually (nudge nudge @richard :P)
I recommend using that one over this one.
There will likely be a lot of changes coming still, as I’m not too happy with the APIs yet. “start story” is weird. “say” not pausing is weird. Setting colors and speed globally is weird. But even so, you can make some pretty cool stuff.
The only thing I don’t understand about the example you provided is that you need to put those blocks inside a start story block. What is the point of that??
Yes, this is admittedly awkward and there’s not a simple explanation, and it has to do with the internals of how MakeCode works. I’m still looking to see if there’s a better design.
Technical reason:
It has to do with how On Start works. Because users might depend on code running in On Start before any other code in their program (like variable initialization, etc), On Start is “blocking” meaning if you “pause” in On Start the whole program pauses and waits, so the game engine can’t render or run update logic.
What “start story” does is spins up a background thread effectively that makes the subsequent calls non-blocking to the main game loop. This allows us to use pause to time the story telling.
On start isn’t blocking, we just move game update events (and a few others) so that they are registered after on start (e.g. https://makecode.com/_epmJx3hyVPHD see that pressing a is reflected on screen even before that pause is up, and that the sprite shows up). It’ll still run the update and render logic, just any of those events registered in blocks won’t be added until after on start finishes.
I would imagine this is actually what you generally want with a story though ( / that you don’t generally want to spin another fiber for this) - if you have an on game update loop that spawns enemies, you dont want it running while you’re talking to the professor to start the story. It should be fine to just drop the wrapping block?