Exit from a loop

Discussion and feedback on Construct 2

Post » Sun Dec 18, 2011 8:15 pm

Hi its me again....
Yes, Im using a For loop from 0 to some boundary. How can I exit from this loop before get upper bondary? Like an "Exit for" ? I was thinking using a sub event but theres no action to exit a loop. Its really necessary for a complex project like mine. Thanks in advance!
Be nice with others and with yourself!
My musics: https://soundcloud.com/vinians
My C2 Forum:
http://nmbr.forumeiros.com/
My Site:
http://www.dicasebytes.com.br
B
21
S
5
G
6
Posts: 166
Reputation: 4,885

Post » Sun Dec 18, 2011 8:26 pm

If you loop from 0 to <var>. Then you can set <var> to a higher number on a condtion so the loop wil end. Woould be nice if CC2 will come with a while condition.
B
31
S
8
G
6
Posts: 29
Reputation: 6,718

Post » Sun Dec 18, 2011 9:26 pm

[QUOTE=Merlino] If you loop from 0 to <var>. Then you can set <var> to a higher number on a condtion so the loop wil end. Woould be nice if CC2 will come with a while condition.[/QUOTE]
Yes, but I was claming for a more clean solutions like a simples "exit loop" or "exit for".
Thanks!
Be nice with others and with yourself!
My musics: https://soundcloud.com/vinians
My C2 Forum:
http://nmbr.forumeiros.com/
My Site:
http://www.dicasebytes.com.br
B
21
S
5
G
6
Posts: 166
Reputation: 4,885

Post » Sun Dec 18, 2011 9:31 pm

In r72's changelog

=> Add System: Stop loop

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sun Dec 18, 2011 9:32 pm

Since the latest release r72 C2 has a "Stop loop" action in the General category of System object.

*Ninjaed by KyatricAnimmaniac2011-12-18 21:33:30
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Wed Apr 27, 2016 1:42 am

please note that "stop loop" does not work for "for each array element" task="hello" in the example.
Image
Image

i have also found that "stop loop" doesnt always work for system loops either (a hard bug to find).
best to have a variable to compare to for each loop so that code in the loop isnt called.
B
4
Posts: 4
Reputation: 208


Return to Construct 2 General

Who is online

Users browsing this forum: 99Instances2Go, Aphrodite, Eisenhans, R0J0hound and 16 guests