What is the difference between "Else" and this?

Get help using Construct 2

Post » Fri Aug 29, 2014 3:05 am

I'm just making a simple pause menu. The events:

WITHOUT ELSE
Image

This was my first try... for whatever reason, doesn't worked. So, I tried with an "Else":

WITH ELSE
Image

And it works fine '-' :?:
So... my question is: the two methods isn't the same thing?
Thanks.
B
20
S
4
Posts: 385
Reputation: 2,270

Post » Fri Aug 29, 2014 3:14 am

Line3 in the first picture is [ELSEIF: Do something], so after that you have "imaginary Line4" with [ELSE: Do nothing].
Line3 in 2nd picture is [ELSE: Do something].

In your first picture, Line3 fired because the variable: pause is updated to 1in line2.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Fri Aug 29, 2014 6:38 am

DuckfaceNinja wrote:Line3 in the first picture is [ELSEIF: Do something], so after that you have "imaginary Line4" with [ELSE: Do nothing].
Line3 in 2nd picture is [ELSE: Do something].

In your first picture, Line3 fired because the variable: pause is updated to 1in line2.


I disagree that it's an ELSEIF

It's basically:

IF <condition1> THEN <action1> ENDIF
IF <condition2> THEN <action2> ENDIF

not

IF <condition1> THEN <action1>
ELSEIF <condition2> THEN <action2>
ENDIF

In the former BOTH actions can execute (and in fact did; thus the OP's problem).

In the latter only ONE action can execute.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 29, 2014 7:04 am

codah wrote:
DuckfaceNinja wrote:Line3 in the first picture is [ELSEIF: Do something], so after that you have "imaginary Line4" with [ELSE: Do nothing].
Line3 in 2nd picture is [ELSE: Do something].

In your first picture, Line3 fired because the variable: pause is updated to 1in line2.


I disagree that it's an ELSEIF

It's basically:

IF <condition1> THEN <action1> ENDIF
IF <condition2> THEN <action2> ENDIF

not

IF <condition1> THEN <action1>
ELSEIF <condition2> THEN <action2>
ENDIF

In the former BOTH actions can execute (and in fact did; thus the OP's problem).

In the latter only ONE action can execute.

Oh yeah you're correct! What I have in mind was the else from elseif is referring to the pause=0 in previous line, I knew this but still making mistake. Sorry @Zathan :oops:
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Fri Aug 29, 2014 7:22 am

Nah it's fine, I knew what you meant, it's just that it might confuse a beginner (not necessarily the OP) :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 29, 2014 9:01 am

Construct 2 runs events from top to bottom. So in your first picture, the last action in line 2 sets pause to 1. It then goes on to the next line and since pause is set to 1 it runs the event. With an Else condition, line 3 cannot run if line 2 runs.
B
8
S
2
Posts: 35
Reputation: 572

Post » Fri Aug 29, 2014 9:19 am

Hey codah just because I am OP you don't have to tell everyone. LOL
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,763

Post » Fri Aug 29, 2014 10:11 am

Lordshiva1948 wrote:Hey codah just because I am OP you don't have to tell everyone. LOL


Now I'm confused! :D
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 29, 2014 10:33 am

codah if you are confused! then you should contact TOM or Ashley through confused.co** LOL
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,763

Post » Fri Aug 29, 2014 8:36 pm

hehehe thank you, guys :)
Now I get it.. in fact, it's very simple.
As Drakkith Said, "Construct 2 runs events from top to bottom".
So, without the else in this case, there is nothing to stop the third line of execute.. it will always execute both lines.
B
20
S
4
Posts: 385
Reputation: 2,270


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Jackriduk, kiki4construct and 30 guests