Why there's no "Else"?

There is something like the code “Else” in programming lenguage? If the answer is: No, Why? And it will be in GDevelop 5?

Event works differently than if-else statement.
An else statement is triggered only if the previous member statement fail while in GDevelop every single event is triggered, to add an Else event and make it work similar would require to make significant changes to the event system for no reason really. You can do the same by simply inverting the condition.

If it true do this
Else do this

If it true do this
If it not true do this.

Same thing.

What would make sense and I have already requested the feature is the ElseIf. It would have number of benefits but the Else on it own has not much use imo.

I don’t think so, at least not in v1. Maybe after but don’t take my word for it.

Well, it’s not exactly the same. Consider this basic case:

if a is true, do something1 and set a to false
If a is false, do something2 and set a to true

Without anything similar to “else”, if a is true, both something1 and something2 will be executed.

With simple boolean condition it’s easy to workaround (first flip the value, then test for negated conditions), but if the value progression starts to be a bit more complicated (like for some state machine), it gets pretty hard and requires additional flags to ensure that stuff that shouldn’t get executed really does not :stuck_out_tongue:

You don’t need to implement fully-featured if-elseif-else memchanism. If you could group events in a way that ensures that at most one event from the group gets executed at the same time, that should be already enough :slight_smile: You could also add an action that skips the rest of the events at current indentation level.

Just reading it, totally missed the post :neutral_face:

Actually, if one of the event conditions is false the actions and sub-events aren’t triggered, so technically it’s possible to add this if/elif/else event (I guess it would be a special event). The problem we faced some time ago, if you remember, was about what to do with object lists, treat them as series (each if-elif works on the same list) or parallel (each if-elif works on its own list, copied from the patent list)?, and in which way the lists get modified, a complex topic :ugeek:

Yes, this is what I had in mind when I was saying events works differently in GD than If-Else statement in programming.
As of now every single event get triggered line by line, an Else would require to change that and have a special event that would be triggered only if the previous event fail and skipped otherwise. But the use case of Else on it own does not worth it, because that’s all you could do with it. “If-ElseIf-Else” would be more powerful than just “If-Else” that’s all I meant.

Also, he or she was maybe coming from Construct which has Else event but, in Construct you are forced to use Else because Construct simply don’t let you to invert certain conditions. I also wanted to point out, there is no such limitation in GD. You can invert all the conditions unlike in Construct if that’s all you want.

Also I was worry about that 4ian going to see this request and forget about “ElseIf” that I have requested ages ago, that’s why I was commenting :smiling_imp:

All parent condition is tested one after the other without exception, that’s all I meant. Obviously if the condition of the parent fail, the rest is skipped but only then, assuming all true then all of them get triggered but in some case you want only one of many to be triggered even if all of them is true :slight_smile:

No, I don’t. Probably I missed that class. :stuck_out_tongue: Unfortunately I don’t really know how GD works at the core level this is why in very complex scenario I get bugs all the time that normally I can solve with “For Each” event and bunch of variables, but an “If-ElseIf-Else” kind of structure would be more efficient and cleaner, nicer in many cases.

True, but what I like in GD is that unlike other event based tools it allow you to think like a programmer and apply the same logic. You can be a programmer and come to GD and use the same concepts or after find GD too limited you can go and apply the same logic you get used to with GD in any other environment. I have used all event based tools out there but GD the only one allow you to do this. So, personally I would prefer to keep that and avoid any unique solutions that would be specific to GD only and can’t be applied elsewhere :slight_smile:

Re-checking it, there were not a problem with objects lists… only, there were problems with everything :open_mouth:
It was also requested in the french side: else, the only topic about it replied by 4ian, saying he isn’t sure if it’s worth it nor how to implement it, then in his second post he has problems with the objects lists too :laughing:
So that’s it, nobody knows how to do it :stuck_out_tongue:

That topic is from 2010 he was still study programming at the time and it is still scares me how can you even remember these old topics, didn’t you win any memory contest?
I’m sure 4ian got more experience now. He can rewrite GD from scratch with no eyes open in a week (168 hours) :laughing:

Good point, why not try to add the suggestion in Trello or open an issue on GitHub (not sure if 4ian is active on Trello)?, so we know if there is a chance about it :slight_smile:

I’m sure 4ian already know what is missing from GD and how it could be improved. It was a long time ago when 4ian commented on a feature request at least here on the forum and there is a reason for that. It easy to ask and suggest new features but 4ian need to consider how much he can take-on to maintain. I’m afraid he has reached the limit the last time he was commenting on the forum on a feature request :frowning:
Things might going to improve with GD5, losing some old features might going to make enough space for some new ones :slight_smile:
I’ll wait and see first how things going to end with GD5 and I throw my list at him after :smiling_imp: (when I see he is open for new ideas anyway)