LoopIndex and LoopLength Query

This forum is currently in read-only mode.
  • I'm having a bit of a trouble getting LoopIndex and LoopLength to work as expected - LoopLength first:

    Say I have a condition of For "TestLoop" from 0 to 1 - I'd assume LoopLength("TestLoop") would be 2, since the system would first run through loop 0 and then loop 1, however LoopLength returns 1.

    If the condition is For "TestLoop" from 1 to 2, it returns 2 as expected. Does looping only work for positive integers?

    As for LoopIndex, does it return the currently processed loop number or the nth iteration of a loop? Say if I have For "TestLoop" from 2 to 3 and I have an action that makes use of LoopIndex("TestLoop") and the system is running through the first loop (number 2), would LoopIndex return 1 or 2?

    Sorry for possibly asking obvious questions, but the Wiki is very scarce on the topic of loop evaluation. Using Construct Classic 1.2

  • Well, it appears that looplength just returns the end number of the loop. Loopindex will return the currently processed loop number.

    ex:

    for 1 to 5

    1,2,3,4,5

    for 1 to -2

    1,0,-1,-2

    for 0 to 3

    0,1,2,3

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you. That clears things up quite a bit.

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