You can leave your suggestions and improvement ideas here.
User avatar
By ddabrahim
#60694 In GDevelop every single event is triggered every frame but in many cases it is just a complete waste of resources.
For example, let say I want to trigger different action based on a value of a variable.

Code: Select allIf Variable = 1 THEN do something
If Variable = 2 THEN do something else
If Variable = 3 THEN do this
If Variable = 4 THEN do that


In case the value of the variable is equal to 1 and I have no intention to change it right here and now, at the time when all this conditions are checked, the value just can not be 2, 3 and 4 and as a result it pointless to check the value of the variable again and again and again and in case we replace the variable with something using more resources, for example with a collision check with different objects, it may also have significant hit on performance.

In a big, complex game there could be hundreds of events and conditions we are wasting resource and performance on when we don't even need it.

In most programming languages it can be solved by using an ElseIf statement and I think something similar an "ElseIf event" could be very useful in GDevelop. It doesn't need to be called "ElseIf" but I just can't think of anything better right now, but the idea is coming from the ElseIf statement. The way it would work, we could decide to use this special event "ElseIf" anywhere as we see fit as main-event, sub-event and it could also have it own sub-events too. When an ElseIf event is triggered and the condition was true and the actions are executed including the sub-events, GDevelop would jump to the next standard (non ElseIf) event and skip all the ElseIf events in between and all the conditions would be just ignored and not checked.

I believe such event could help with optimization and performance but not only that. At the moment if we want to create a switch we need to apply some variable tricks, by using an ElseIf event we could simply just use 2 events to make a switch.

Code: Select allElseIf switch = 0 THEN switch = 1
ElseIf switch = 1 THEN switch = 0


This way, in case the switch is 0, we set it to 1 and because the ElseIf event is executed, the next ElseIf would be skipped this time. By using standard event it is just won't work because as soon as we set the switch to 1, the next event would be triggered and set it back to 0 but the most important use case of ElseIf would be optimization.
User avatar
By ddabrahim
#60697 What do you mean by "selected" object?
The elseif event would work exactly the same as a standard event with the addition, if an elseif event get executed it would tell GD to skip further elseif events until find a non elseif event. After that all the events would be triggered again as normal until an elseif get executed again then skip the elseifs.
User avatar
By ddabrahim
#60885
He's basically asking for break;

Not exactly.
"Break" is designed to terminate the statement or loop it is used in and jump to the next one.
"ElseIf" is designed specifically to be triggered/checked only until one of many is executed and after skip the rest.
User avatar
By ddabrahim
#63314 Since 4ian is working on the new event editor I thought it would be the best time to bump this topic up again and hope 4ian don't miss it, I still believe it would be extremely practical and useful in huge complex projects.