LoopIndex and LoopLength Query

For questions about using Classic.

Post » Sun Jun 05, 2011 4:55 pm

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
B
8
S
2
G
2
Posts: 85
Reputation: 1,218

Post » Sun Jun 05, 2011 6:11 pm

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
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Thu Jun 09, 2011 5:46 pm

Thank you. That clears things up quite a bit.
B
8
S
2
G
2
Posts: 85
Reputation: 1,218


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests