I have the following repeat loop in an event sheet, and I want to be able to exit the loop arbitrarily. I figured by setting the value of the global allowLoop variable to 0 that the loop would stop running, but it doesn't. I even added a button in the layout to manually set the allowLoop variable to 0, and verified the zero value when clicking the button. What am I missing?
This generates 100 Wait threads immediately, all timing out at the calculated time. Use the Timer behaviour to do what you want. You have complete control on stop/starting a Timer. You have no control over Wait.
Thanks for the explanation. If I understand how a timer would work (it's quite possible I don't), I'd need to move the action outside of the function it currently sits in, so it falls in the topmost flow of the event sheet, and enable/disable triggering of the action using the allowLoop variable. Is that right?
In any event, I wound up using (what I believe is) a recursive function with a timed delay since it's something I can explicitly call at any time. Seems to work OK.
Develop games in your browser. Powerful, performant & highly capable.
You can do it like this:
If you want a flexible Timer, set it to "Once", enable the the last action and put a variable in it.
Thank you kriand, this is really helpful. I'm not new to programming, but I'm still quite new to Construct and need to figure out all the Construct ways of coding.