Does "Happens After" actually work in scripts?


I’m having trouble getting a series of scripts to trigger. I have a rather long intro for a level, so I was hoping to organize it into a few scripts that would trigger one after the other. The first script has the event “god:new-world-created” and an ID of “Intro”. Then the next script has an event of “surface:frame-changed” (not sure if that’s the right event, but couldn’t come up with a better one and other people are using it) and a “Happens After” that refers back to the ID of “Intro”. However, when I run the level, only the last script defined triggers regardless of what order I put the “Happens After” clauses in.

Am I using this incorrectly, or is something broken?


Happens after means the first script needs to be triggered before the second can be triggered. One thing about scripts is that if a second script is triggered, the first will ‘yield’ to it. This is so that ‘skipping ahead’ is easier to do (like if your next script is based on the user clicking a unit in a tutorial, if the user clicks the unit early the next script will begin and the ongoing script is immediately terminated). What it sounds like is happening is:

  • Script A is triggered and begins
  • Script B is triggered immediately after
  • Script A yields to Script B, fast forwarding through all its actions
  • Script A looks like it never happened.

You can check this by opening the JS console logs and seeing if the Intro script is triggered and then ended.

The solution would typically be to trigger Script B with something that will only happen after Script A is complete, like if the player clicks the play button. Does that make sense?


OK, that makes sense. Is there an easy way for me to have some custom flags that I can trip if the first script is either skipped or completed, and then have the second script not trigger until that flag is tripped?

I’ve split my intro up into three scripts for organizational purposes, and the user won’t really have any interaction until the third script, so I’m having trouble coming up with a way for the second and third scripts to trigger at the appropriate times.

Should I have just kept it all as one gigantic script?


Having it all in one gigantic script I think would be the best solution. You could also have scripts B and C triggered off ‘script:ended’ with the event checking against the scriptIDs of A and B respectively. You’ll have slightly different results when you press ‘escape’ in these cases I think. If you make it one gigantic script, I believe pressing escape will take you to the end of everything, while if you break it into three pieces, pressing escape will take you to the next script. Something to try out. This is assuming none of your actions have skippable set to false.


Do you mean the event should be “end-current-script”, or is there a hidden event called “script:ended” that I’m not seeing?