Question about trigger once

Do you know that feeling when you think you’ve finally understood everything and then you realize…
you actually haven’t?

Today, while I was writing a bit, I noticed something… this.

I always thought GDevelop executed conditions/sub-events in an orderly sequence.

Does this mean that in conditions like in this case,

the t.once part is executed last and the others run first , or am I just interpreting this completely wrong?

I mean… I know that, chronologically, the action gets skipped if previously was already true…But what about the execution order in the example above?

I think it just means that if there are multiple conditions within ONE event then trigger once should be last. In fact, I think there was even something introduced a while back that automatically put the TO at the end when pasted in or moved or something. Not sure what it was as I don’t think it always works.

However, I remember that there was an optimisation suggestion for a click condition that had this order - left mouse button down, trigger once, cursor is on object. Events arrangement and Hide and show event (SOLVED) - #5 by arthuro555

1 Like

Yes, that part is pretty common.
Now part of that problem has been fixed…considering the new “just pressed” conditions… and I guess for clicks it’s no longer needed.

But what about the sub-events? Or maybe the main events themselves… does it mean they get executed at the end, or am I interpreting this the wrong way?

EDIT:

Ok, I get what you mean… that in a group of conditions, the “t.o” one is always executed last in the list.If that’s the meaning, then I can relax.

I’m pretty sure all that means (the text circled in red) is that trigger once will appear at the bottom of the list of conditions.


And yet…it can be dragged to the top. Very weird.

I’d probably submit this as a bug report, as I’m not sure if it’s an intended feature.

I don’t think it’s a problem or a bug… because sometimes you want something like a keypress, with a Trigger Once right under it, and then maybe an `animation frame > 1 as the next condition where you don’t want Trigger Once. At least for me, ever since I’ve been using GD, it has always worked this way…
but ofc what described in the TO feels strange.

1 Like

True.

I understand where dragging it might be useful. Whether or not it is an intended feature, I’m not sure, but maybe it shouldn’t be classified as a bug. :smile:

This is similar to yours. I added text actions to follow the flow.

Each event is evaluated in order. With the trigger once event only being triggered once. The last event isn’t a subevent of the trigger once, so it gets processed.

GD tries to keep the Trigger Once as the last event but it can be moved and it will be evaluated in sequence.

Take these 3 events. They’re very similar.

The first event will rotate NewSprite1 once everytime the mouse is down and the cursor is on the object. But, because the trigger once is last, you can hold the mouse and swipe back and forth over the object and it will spin a little each time. All of the conditions are factored into the trigger state. So, moving the cursor back and forth causes the cursor is on object condition state to repeatedly changes between true to false which resets or removes and adds a trigger once state.

The 2nd event does the same but bc the trigger once condition only monitors the mouse is down condition when you press and hold the mouse, it will only rotate NewSprite2 once. Plus, because the mouse is checked first, it will only rotate if the cursor is over the object when the mouse is pressed. It only gets one chance per press. So, nothing else will be process after the first time.

The last event is the same as the 2nd event. It’s my preferred way. It’s more structured. Easier for me to understand.

1 Like

I know this topic’s concept but do you mean this?

Yeah, it’s like I replied to Snowy above… I think.

So why does the description say “the condition is executed last in the list”? **I guess in the end it was just an interpretation of a very specific situation, without taking all the other cases into account.

2 Likes

Mabye, it refer to this… hmmm

1 Like

Well actually it says ‘This condition is always last in the list’. And for years I believed that because that’s what it said. So maybe it could be worded better.

3 Likes

That definitely seems contrary to the description, which seems to say that Trigger Once will always be evaluated last for the condition block it is in.

Have you tested this recently? I wonder if the evaluation order was changed and they just forgot to update the description?

The description is confusing. Since, it’s neither always last or evaluated last. The app does try to keep it last. If you already have a trigger once and click the add a condition text, it will add the new condition before the trigger once.

Maybe, in the past things worked differently. Or maybe, they believe that it’s easier to understand the logic when the trigger once is last.

There’s nothing to prevent you from using multiple trigger once conditions in the same event but that would be extremely confusing looking. I think they prefer breaking the logic into subevents.

3 Likes

I’m wondering what happened if multiple “Trigger once” had checked in the condition list at the same time. Hmmmm. (sorry for small grammar mistake)

1 Like

The trigger once conditions would all be evaluated the first time but on the following frames only the first trigger once would be evaluated.

Think of it like having a hallway full of doors and locking each door behind you. The first time, you could walk through the entire hallway. The next person would be stopped by the 1st door.

You could put a condition in between each trigger once. That would be confusing and probably unnecessary since the first trigger once would control the process. Resetting the first would reset them all.

2 Likes

The trigger once’s go off the screen, and yet it still won’t trigger twice! :laughing:

1 Like

What??? :skull:

1 Like

Ah, that makes more sense. So a better description might be “This will appear last in the list and it is recommended to keep it there”?

It is a bit unusual to put it in the middle of a condition block, I would move the rest of the conditions to a sub-event for clarity

1 Like

I’m in favor to remove that sentence…
since the use/place of TO is subjective (as long as properly placed)

Mh… how I had understood this was, that the trigger once state will always be checked last in terms of order of operation. So it is useful to know, that using this will not make your events more performant, since all previous conditions will be checked, before the trigger-once-state is checked.

I don‘t believe, that it will be checked after following conditions, because those are not relevant to the „trigger once“.

I also don’t think that it (the statement we are talking about) has any implications on where to put it. You need to always put it below all events that you want to apply it to. The conditions, which are not trigger once dependend, need to go below this condition.

I actually don’t use this condition anymore. It seems to always be better to use your own states.