Or event and else

I know there is no else event so I wonder how I can do the following

If event 1 or event 2 then do Action 1

If neither event 1 nor event 2 then do Action 2

You can use add or and not conditions separately or mixed . You can also put multiple subevents on the same level as each other.

For an if then else You can use opposite comparison or invert the condition.
If A<7 then do something
If A>=7 then do something

You can also use another variable. I like to use a boolean. Set it to false first.

This is like an else or a select case

Set Changed=false

If a =1 then set changed =true and do stuff
If a =2 then set changed =true and do stuff
If a =3 then set changed =true and do stuff

If changed =false then do something

Edit: this was a poor example it doesn’t need to be the same variable or condition type. This was an attempt at an easy to understand example. In this case the last event could’ve been if one of these a< 1 or a>3. The other events could’ve been unrelated like a collision, a mouse event or whatever. In some cases it’s easier to invert conditions. Other times it’s better to use a variable instead of repeating a more resource hungry event. It’s quicker to check a bollean than repeat a formula or check for collisions between a lot of instances.

There are a lot of different ways to arrange conditions, events and subevents.

Thank you for your answer, I knew that, I was hoping for a simpler way
to deal with multiple not events.
At least using booleans might be a bit simpler.

1 Like

In some cases this can help. (Inverted conditions)

1 Like

Could you post a screenshot of your not events. Maybe there’s another approach?

If it’s something repeatative maybe you can make an extension. It’s a shame we can’t make custom events like while where you can put other events inside of them. You could make your own If… Then… Else… Event.

I wonder if you could make separate if, then and else conditions or action. At a minimum they could handle a boolean in the background. The if could reset a boolean, an action could set it to true and an else condition could use the boolean to decide whether to trigger its actions or subevents. Maybe even an advance if that would take parameters.

It might not reduce the code by much but it would add better structure.

IDK. I’m just thinking out loud.

Sorry for the late reply. Here is a screenshot of what I am doing. It is working the way I made it. But I am wondering if there is a simpler approach.

I tried to use not “BLUE” and not “JOKER” but it did not work.

Hmm. That’s weird. The opposite of
one of these

Would be
Var ≠ “blue”
Var ≠ “Joker”

What do the buttons represent? What happens?

Is it possible to put the buttons in a group and use the group name and only 1 set of events?

yes that is what I would expect but it always triggers the ≠ condition

https://fildubek.itch.io/color-of-word This
is an old version of the game that I wrote in javascript a long time ago. I am trying to remake it with gdevelop because the old code is a mess.
The game displays the name of a color for example “Blue” but the font color of the word can be a blue or another color. The goal is to choose the correct color of the font and the color that the word says by pressing one of the buttons.
I have added a new feature called Joker where any button can be pressed and will count as correct.

I’m not sure why it wouldn’t work for you. What about this? Compare the button label and the variable.

I used rotation just as a way to test it.

Hmm unfortunately no it does seem to work. Maybe something other event is interfering with it. I think I will leave it how it is now. Having five conditions for each button that trigger the lost scene. Thank you for all the help and effort. :slight_smile:

1 Like