For loop event followed by else event

Just started using Construct 2? Post your questions here

Post » Sun Dec 28, 2014 6:57 pm

Whenever i used else event after a for loop event, both events run. How do i make it so that when the for loop event runs, the else event will not run?(not using subevent)
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Sun Dec 28, 2014 7:05 pm

You can't use Elsa after a For. Maybe post a snippet of what you are trying to accomplish.
ImageImageImage
B
71
S
21
G
231
Posts: 3,695
Reputation: 129,366

Post » Sun Dec 28, 2014 9:41 pm

Why i cant use else after a for?
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Sun Dec 28, 2014 9:59 pm

StormHo wrote:Why i cant use else after a for?


You can, but what does it mean? And what does it mean in your logic (i.e. what are you trying to do)? Can you provide a sample capx?

edit: thinking about it, it does make sense in a C2 kind of way. i.e. if the For loop picks 0 instances, then the Else should trigger(?). In which case you might be right that it shouldn't always run.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Dec 28, 2014 10:18 pm

use the debugger preview to check the variable,pause and press step. each step u could see increment of 2 meaning that both events are running
You do not have the required permissions to view the files attached to this post.
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Sun Dec 28, 2014 10:30 pm

StormHo wrote:use the debugger preview to check the variable,pause and press step. each step u could see increment of 2 meaning that both events are running


Yes I agree it seems that the Else shouldn't fire. Personally I wouldn't use a mechanism like this, but if it's supposed to work like that..

edit: I have a theory. A For loop ultimately stops because the condition becomes false (no object is picked). Perhaps this triggers the else.. (actually that's true for a 'normal' for-loop but maybe not for For-each)

(Just for reference)
Else
Run if the previous event did not run. Note that this condition does not pick any objects: if it follows an event that picks objects, in the Else event all instances revert to picked again. Else can only follow normal (non-triggered) events. It can also follow another Else event with other conditions to make an "if - else if - else" chain.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Dec 28, 2014 10:50 pm

As in a normal person view,Else should not fire because the For Each loop has picked objects and has been finish running just like other conditions. Hopefully C2 team can look into this.
B
17
S
4
G
1
Posts: 203
Reputation: 1,583


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests