Feedback: 'Else' condition

Discussion and feedback on Construct 2

Post » Mon Apr 09, 2012 1:35 am

@Ashley :D yeah I saw my mistake and thought about something else as a solution

So I reposted it with some changesYann2012-04-09 01:35:45
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Apr 09, 2012 1:59 am

"Else" is pretty tricky indeed when you consider it in the field of C2.
Programaticly it's strictly logic : did the code block before executed or not ?

I'm wondering about a case of use:
if, elseif, else

So so far, else as been evoked in "simple case tests" if I may say so, where you have actualy "workarounds" in C2 by inverting conditions or "duplicating" with different comparison operators, and where it's a simple matter of if, else.

How would the C2 "else" handle a "more complex" structure:

[code]
Var1 = 0
-> do this
Else
Var1 = 1
-> do that
Else
-> do whatever
[/code]

I'm aware this can be achieved already and doesn't require an "else" to do.
The interest here, though, is to make sur that if the code in the last event "else" is executed, it implicetely means that all events "linked" above did not execute/their conditions were false.
This is something else that can be worked around but what I expect from an else is to handle such a structure for me now.

So my question @Ashley here is is the "else" currently planned to take several top levels into account, and if so how would that impact on the "picking" side ? (also are you planning the little visual links like in CC between top and "else" events, it wasn't on your screenshots and I really liked those ^^)

I might come later with more feedback on the subject it is just indeed really tricky once you start to think about it.
Also, since I've used C2 from the start without else, and tools have been given to workaround, it's actualy pretty hard to think about how I would use it and expect from it on usage.

Kyatric2012-04-09 02:01:39
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 » Mon Apr 09, 2012 3:43 am

IMHO "Else" should be strictly logical just the way real programming works,
especially since you want it to be conceptually simple.

On this example :


I know it looks like a really convenient & obvious way to do a picking,
but i think it will turn confusing really quick in a more complex example.

Also when you teach a beginner class/kids to use Construct 2,
this will messed up with how "If..else..." works in their mind when they start learning programming language (or if they already learn the basic of it).

Conclusion:
[code]
+ If Condition A is fulfilled
     -> Action 1
     -> Action 1
     -> Action 1          
+ Else
     -> Action 2
     -> Action 2
     -> Action 2     
[/code]
Only one side of Action can run at one time, either Action 1 or Action 2.

This makes things easier to debug/read too,
because you can be sure that when Action 1 is running, Action 2 will never run,
you don't have to debug both sides because there is no chance that will happen (unlike that picking example above).Potato2012-04-09 03:43:55
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Mon Apr 09, 2012 3:52 am

Agree with @Potato says. Keep it simple, stupid.
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Mon Apr 09, 2012 12:41 pm

[CODE]
EVERY TICK               do something
ELSE                      ????

FOR(...)                  do something
ELSE                      ????

EVERY X SECONDS           do something
ELSE                      ???
[/CODE]

what about those cases?

Also, what happens when you chain the else, like adding extra conditions to the else, and then adding an else to that and adding even more conditions to that other else and so on?Fimbul2012-04-09 12:42:59
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Mon Apr 09, 2012 2:08 pm

[QUOTE=Ashley]
Of course, experienced users see that this sets X to 1 then immediately back to 0 in the next event. However, using 'Else':

+ If X = 0
-> Set X to 1
+ Else
-> Set X to 0

This works as intended, toggling X between 0 and 1. However, your proposal to make 'Else' the equivalent of the inverted previous event will break it again, making it work like the first example![/QUOTE]

A bit off topic I agree, but perhaps some experienced users aren't aware of the "short" version of toggling between 0 and 1 without ifs:

Set X = 1 - X.

Now back on topic, after reading more here's my suggestion:

For logical conditions, ELSE should be "programatic" else, i.e. did it execute or not.

For Picking conditions: "Else" picking should be done at the same time as the "IF" picking and should be the exact opposite. So let's say you have 5 sprites, 1 on the left of 320, and 4 on the right, then you do:

Sprite->X > 320 -> do something
ELSE -> Do something else

it should execute accordingly. BUT, IF in the "do something" you move some sprites, then the "ELSE" should not pick those sprites, even though by the time the flow gets there, they match the ELSE too. Think of it like "programatic" if on a "per instance" basis.

Like: "For these instances, did the logic under IF execute or not? If yes, don't pick them on the ELSE, otherwise, DO pick them, REGARDLESS of what happened to them and whether or not they match the inverted condition as well by the time the "flow" gets there"

This as far as I can tell is the most "honest" implementation of ELSE.

And @Fimbul, the else in your scenarios should do exactly what the inverted does currently. You can invert "Every tick", "For" etc currently, I didn't try to see what it does in practice, but you can invert them and the ELSE for those should do exactly what the inverted does currently

B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Mon Apr 09, 2012 2:25 pm

@Geo: what's the practical purposes of "inverted on every tick" and the logical/practical purpose of "inverted for" ?

As far as my test goes, "inverted for" makes the application crash (firebug error,grey screen in browser) and "inverted every tick" just doesn't execute (logicaly).Kyatric2012-04-09 14:25:41
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 » Mon Apr 09, 2012 2:46 pm

[QUOTE=Kyatric] As far as my test goes, "inverted for" makes the application crash (firebug error,grey screen in browser) and "inverted every tick" just doesn't execute (logicaly).[/QUOTE]
Sounds like a bug - both events need the "not invertible" flag. Will we have a "not elseable" flag?

Personally, I'd prefer if else were not a condition per se, but a special case - a condition "mode" if you will, similar to how inverting is not a "invert this condition" condition or how a sub-event is not a "treat this as a sub event" condition. Because else acts on the previous condition, it follows that it should be special, not a simple condition (because it is not contained to its line).

IMHO, treating it as an ordinary condition is a mistake, hence the confusion. Set some time aside to think of an appropriate interface for it - we also need one for OR. Remember that this decision will "stick", and it won't be easy to go back and change it.Fimbul2012-04-09 14:52:54
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Mon Apr 09, 2012 2:53 pm

Ok so if we can't have 2 else maybe we could have one with options :)

This could be either Logical (1 at a time) or picking

If Condition A is fulfilled
     -> Action 1
     -> Action 1
     -> Action 1          
+ Else
     -> Action 2
     -> Action 2
     -> Action 2

Logical could be default and we could enable picking with a tick box or something...

B
28
S
2
Posts: 69
Reputation: 1,491

Post » Mon Apr 09, 2012 4:17 pm

If I remember correctly, multimedia fusion 2 has two kind of "or". An or "logical" and an or "filtered".
Even with the experience I have with mmf2, cc and c2, I think I really understand this design choice now (well I dropped mmf2 long ago...)
Anyway, if it's that hard to understand, it's probably not a good choice.
So, I don't think having a logical and filtered else would be a good idea...
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: LoneVox, Silverforce, Unconnected, Zebbi and 10 guests