(Solved) For the Repeat event add an index counter

I use this construction a lot:
Repeat VariableChildCount(someArray) times:

and getting a working index into the array is unnecessary complex:


as you cannot add a variable on the Repeat event itself so you need to put the Repeat event UNDER the index (i) declaration.

I would suggest that the Repeat statement is enhanced to
Repeat x times, store the index in <variable>:
a bit similar to the For each child variable (which stores the child)

This is a finalized feature; it will be in a release within 1-2 weeks.

5 Likes

Are we getting closer to the classic for… Next? That would be nice.

For variable start at 0 end at 10 step 2

For variable start at 10 end at 0 step -2

For variable start at 0 end at 10 step .5

I don’t think there’s an equivalent to that in Javascript, so I don’t think you’d see that in events, but anything is possible?

1 Like

It’s not as clean as the basic For… Next but close.

Silver-Streak mainly said that a custom step is not common, even in code.
Basically, in GDevelop, the step will be the classic i++.
If you want a custom step, you will have to use the index and do the calculation yourself inside the loop.

2 Likes