It's actually very helpful in a few instances as it's one of the few techniques that allows some measure of finite control. However it is a problem due to how it works. Personally the only time to use wait are for automated sequences. if at any point there is a possibility of interuption or reset, then wait will hurt. It's best to use Timer.
I'm not sure about the top level reference either. Are we talking about UI or are we talking about how all programming is in C2 is Functional and not say Object Orientated, which would be I suppose downward up.
Replied before I sents.
Wait doesn't hold the program. Wait encapsulates the current set of information and starts a JS Timer to execute after the given period of time. However once doing so obliviously moves that piece of code out of our control.
As I said its not because Wait() can't be useful, my point is that its shouldn't be needed at all, at least not when it comes to solving problems, or what to say.
I don't mean like if you throw in a wait of 10, then nothing will happen in the program for 10 seconds. What I mean is that you create a "fake" break in your program that shouldn't be needed.
Actually wait has it's uses, you just haven't encountered them yet.
Like pressing a sprite button. You switch the buttons animation, wait one second, and switch it back.
Having to also set up a trigger to switch it back is as silly as wait(0).
or like not allowing a key to work for 3 seconds after it's pushed:
Using wait for something like a button and the audio in your examples can be ok. But you might as well hook up a timer. That when its up, triggers and you act on that. So my point in general is not that Wait() is broken and can't be used at all. But again it shouldn't be necessary to use to solve problems. You using it for a button or for the audio is fine. But you are just showing how it can be useful and that is not what im talking about.
So to show you the problem and this is of course a simple example, but if you have a huge game and you solve problem using Wait() its could/will cause problems.
Imagine we have a game where we spawn a Unit (Red square) based on this unit we want to spawn something else (Green square), but depending on some settings we might spawn different things. In this example I have only added one which are the Green square, just to keep it simple. But imagine it could be a Blue, Yellow, Black or a Pink square, all depending on some value when the Red square is spawned.
So the Red square have two variables A and B and we assume that based on whatever, we ended up spawning the Green Square and we store the UID of the Red Square in the Green one. So when you hit the button to create the squares, we want Red Sq. A to be 1 and B to be 2 and write the UID stored in the Green Sqr. as well.
In the top part of the image when I click the button it fails so all it writes is 0.
Adding a Wait(0) in the Green square create event and then trying again, will solve the problem and now the values are correctly read and written to the text objects.
So Wait(0) can be (mis)used to solve problems like this to fake It going to top level, instead of just having the Red and Green squares exist straight away, so the wait is not needed. So the code would do the same thing but the Wait(0) could be removed.