For loop event followed by else event

  • 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)

  • You can't use Elsa after a For. Maybe post a snippet of what you are trying to accomplish.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Why i cant use else after a for?

  • 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.

  • 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

  • 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)

    [quote:33bbbh0k]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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)