How do I stop a loop from repeating?

Get help using Construct 2

Post » Wed Apr 22, 2015 6:41 am

Hi all. I'm not sure if it's some setting I've tripped or something (seems unlikely) but it seems my loops now repeat forever. Perhaps I'm misremembering, but when I had a "For X to Y" loop as the sole condition of an event, it would simply run one loop spanning X to Y. Now it seems like the loop repeats itself infinitely unless I add another condition which explicitly prevents it from running. Was this always the case?
B
52
S
24
G
18
Posts: 295
Reputation: 13,090

Post » Wed Apr 22, 2015 7:19 am

Without seeing the setup of your events it's impossible to say what the issue is..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 22, 2015 9:30 am

Per the Manual:
Loops
Loops can be stopped with the Stop Loop system action.
B
36
S
10
G
4
Posts: 250
Reputation: 7,963

Post » Wed Apr 22, 2015 10:05 pm

It's a basic For loop, as in "For "xyz" from 1 to 100". There are no other conditions together with it and no other events which call for this loop or anything as it was meant to run at the beginning and never again. IIRC it used to do just that, but after running it a few times it turns out the loop begins running again after it finishes, so I've had to add a basic flag that gets set off and prevents it from running again. It's not a big deal, I was just wondering if I've inadvertently messed with some setting or something because I could've sworn it didn't used to do that. Perhaps I'm confusing C2 with CC.

Anyway, thanks for the replies.
B
52
S
24
G
18
Posts: 295
Reputation: 13,090

Post » Thu Apr 23, 2015 3:26 am

add trigger once condition, or set your loop as a sub event, for example :

on start of layout ->
(add sub event) for()
on function("loop")
(add sub event)
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666


Return to How do I....?

Who is online

Users browsing this forum: AllanR, BackendFreak, brunopalermo, farsen, ST314 and 29 guests