For Loop and wait

0 favourites
  • 3 posts
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • Why this is not working??

    <font face="Courier New, Courier, mono">

    For "slowDownLoop" from 1 to 5

         txtBox set text to "LoopIndex: " & LoopIndex("slowDownLoop")

         System wait 1.0 seconds

    </font>

    Every time the loop runs it sets the txtBox to "5" from the beguining, I would like to see the counter increment every second but its not happening that way.

    Thank you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Seems that each loop cycle is excecuted one after another not respecting the wait, so I tried this:

    <font face="Courier New, Courier, mono">

    For "slowDownLoop" from 1 to 5

         System wait 1.0 * LoopIndex("slowDownLoop") seconds

         txtBox set text to "LoopIndex: " & LoopIndex("slowDownLoop")

    </font>

    but by the time the first second has passed the Loop has already finished running and the LoopIndex is already "5"

    Can�t figure this out without using a helper variable.

  • The whole loop is executed in one tick, you can use search to find some discussions about it :)

    After the wait event the loop is not really executing anymore, so you cannot refer to loopIndex anymore. You could do it like this:

    variable = 0

    for 0 .. 10

    .. wait loopIndex seconds

    .. add 1 to variable

    .. set text

    Why not use 'every 1 seconds' event to set your text rather than a loop?

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