How do I use loopindex in a repeat after a wait?

Get help using Construct 2

Post » Sun Nov 02, 2014 10:13 am

Hello,

I read the tutorials to the wait-function but the loopindex is not working as I expected.

I'm trying to work with the loopindex after a wait, but it returns -1 everytime.
loopindex1.png


loopindex2.png


I expected it to return 0,1,0,1.

What am I doing wrong? Is it a bug? Or what can I do, to get the index after the wait?

Thanks a lot!
You do not have the required permissions to view the files attached to this post.
B
5
S
1
Posts: 15
Reputation: 405

Post » Sun Nov 02, 2014 10:21 am

The loopindex was reset because of the wait is the finished in other tick. The loopindex is cumulative only in the same tick, which works exactly like a local variable.

To get the intended result, you need to store the loopindex in a static variable.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sun Nov 02, 2014 10:34 am

Thats not possible, cause the function with the repeat can/will be called multiple times simultaneously. The only way I can think of, would be, to create a variable dynamicly dependig on an given id in a dictionary and refer to it later on. not very beautiful, but I guess it will fit.

but construct 2 saves the position in the event and the used objects when leaving the event cause of a wait... wouldn't it be possible to even save the repeats and their indices? sounds like a featurerequest.
B
5
S
1
Posts: 15
Reputation: 405


Return to How do I....?

Who is online

Users browsing this forum: mcscooter and 24 guests