Actually, The main problem when we trying to make a switch is that, all the events are triggered every frame but it should stop once it switched.
Normally when I want to make a switch sort of thing, I’m always doing something like this to make the event stop:
If Space key is pressed : key_pressed = 1
sub event - switch = 0 and key_pressed = 1 : switch = 1 and key_pressed = 0
sub event - switch = 1 and key_pressed = 1 : switch = 0 and key_pressed = 0
I agree on that this kind of solution can look over complicated but really we need something like this.
So instead of forcing the ELSE way, how about the have a special event dedicated to make switches?
The event would require to have at least one condition and we would required to use sub events to add actions. The event would have no space for actions only for condition.
This way, GD would gently force people to use sub events to add actions, it could have two by default to help people get the idea. So, when GD trigger this event, it would trigger only one sub-event at the time that is true. When a sub event was true and it actions are triggered, it would stop similar to my “dirty” solution above and other sub-event would be not triggered until the main condition fulfill again.
The event would have no limitations really, it could have any condition and any number of “main sub events” and move from the first one to the last one and stop once any of the (main) sub-events was true and the actions are triggered. This way we could switch between any number of states but only one of them can be true at the time.
MAIN SUB EVENT 1
MAIN SUB EVENT 2
In my opinion this solution could be better because it would be straight forward what is it for and how to use it also looks and feels home in the editor in my opinion and unlike with ELSE, it would trigger the first sub-event that is true and stop instead of waiting for the previous event to be fail.
Only to see the different, my above over complicated example could looks like this using such event:
Space key is pressed
sub event - switch = 0 : switch = 1
sub event - switch = 1 : switch = 0
I was just thinking about it and I have realised what I have described above would still require us to make sure the sub-events are actually switched. So how about that if it would be automated? Always the first sub event would be triggered first and then stop, after the second, and then stop and after the third and so son. Of course the condition still need to be true in case a condition is fail, it would jump to the next one in the row. but in case the condition is true or we don’t use condition it would be triggered in order first to last.
So, by doing this way my above example could be like this:
Space key is pressed
sub event - no condition : switch = 0
sub event - no condition : switch = 1
sub event - no condition : switch = 3
So yeah, there is basically to way of doing this in my head:
One way of doing is the event would check each sub-event from top to bottom and trigger the first one that is true and then stop but next time start all over again from the top.
The other way of doing is, the event would go in order from first to last and trigger the event if it true and then stop but next time it always start from the last triggered sub event and continue the row to the last.
Maybe we could choose when we add the event if want it to move from first to last sub event each time or we want it to start each time from the last triggered sub event and continue the row to the last.
It could be also two separated event just to keep it simple…