counter for 'for each' loops?

Get help using Construct 2

Post » Sun Jun 09, 2013 9:42 pm

First, I would like to say that what you all are doing is awesome.

Second, I am having a problem finding a solution for a counter I can use in my 'For Each' loop.
My 'for each' loop used to be a function, and I was using the (loopindex) parameter to count & Function.Param(0) to access the number.
This was very nice because I could give my object an ID that was tied to the Function.Param(0) and then access an object in an array that had the correlated position based on the Function.Param(0).

The problem with it being a Function was that it was doing things all at once, without recognizing my sub-events.
So then I decided to change it to a 'for each' loop, and things are working wonderfully, except I get an infinitely repeated error that says I cannot use the Funtion.Param(0) call because it is not a function... that is totally understandable.

So, I really want to know if there is some parameter I can use to keep count of how many times my 'for each' loop runs.

As an alternative, I was thinking, since the 'for each' loop is 'for each (instance of object)', that I could give my object instances IDs and use that to attach to my other object created within the for each loop/use it to access things in the array.
But if there is a counter similar to Function.Param(0) that can be used in 'for each' loops I would love to know.

Thank you all so much.
B
8
S
3
G
1
Posts: 6
Reputation: 1,144

Post » Sun Jun 09, 2013 11:14 pm

Not sure to understand your issue, but are you aware instances already have an IID and UID values you can refer to and pick ?

You still can use the expression "loopindex" with a "for each" loop.
Also, if you want to check the number of iteration of a loop, you could also have a local variable and add 1 to it, this will allow you to keep some kind of counter.

Possibly posting your capx would make it easier to understand what your issue really is.
Kyatric2013-06-09 23:14:22
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
276
S
103
G
84
Posts: 7,287
Reputation: 83,089


Return to How do I....?

Who is online

Users browsing this forum: alajajm, ankas, iBarin, whitephon and 14 guests