0 Favourites

How do I stop a loop before its suposed to end?

  • I'm at my wits end with this, I'm sure its an easy solve, so I would appreciate the help.

    In the game I'm making, I have a layout set up so that when you press a button, I want it to keep appending text on a new line until one of two conditions happen.

    for testing it, I set up a button to end the loop, but I cannot get it to work. I've tried doing while loops and adding a [wait 2*loopindex] but keep getting indefinite loops and its not waiting like it should, even when I put a [on button click end loop] in the events.

    Any help on this?

    I want to start just append text to a text block until either a button is pressed, or a random event (Which is controlled by time and a random number) happens.

  • I would do it without a loop. Make an extra global variable that act like a boolean like 'isAppend=-1'

    Then you could use this:

    System| isAppend=1 -> 'Append your Text'

    Button| on clicked -> System| set isAppend to isAppend*-1

    random event triggered -> System| set isAppend to -1

  • Thank you. If I add a wait, will this continue to append text until the even or button changes the variable? That's why I figured I needed to use a loop, to keep it going until I'm ready for it to stop. I apologise that I'm not about to just test it, wrong be near a computer until later tonight.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • For the sake of clarification, a loop will always run until one of two things happens: its terminating condition becomes true, or the break action is called from within. Until a loop has terminated, nothing else will run, so it's generally a bad idea to wait on external input to terminate a loop.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)