Pointers for GDevelop

I was wondering if it was possible to make an event command that allows an action to refer to another action along the event list. Basically this feature would allow me to have better control over what actions happen in which order along the event list instead of the default “Top to Bottom” order. Main reason I want this feature is for better ability to organize my events without having to put them in a non-intuitive order just for them to happen in the correct order at runtime. This has also been a pet peeve of mine as it makes debugging a choir to do since you can’t always order your events the way you would like to just due to this limitation with the engine. Or in some rare cases, despite having them in the “Correct Order”, they seems to not work in the order they are suppose to anyways. And I am sure ALOT of other people would appreciate such a feature as well.

1 Like

Suppose this is implemented: if you point to an action that isn’t at the top, there will be actions both above and below it,so how will you determine which one to execute next?

Or let’s suppose you can number the entire sequence of actions,what would change compared to simply ordering them as they should be?

isn’t the correct order just one?

Are you talking about events and event groups? Just so I understand. You’re not talking about the sequence of individual conditions or individual actions within an event?

It sounds like the way older languages worked when you needed line numbers. You had commands like goto and gosub. It’s been awhile since I used a numbered language.

Example:

10 print “Hello world”
20 goto 100
50 do something
60 end
100 print “end”
110 goto 50

It reminds me of the choose your adventure books.

This allowed you to create non-linear execution. Although, IMO it was more difficult to follow plus you could run out of line numbers in a section causing you to have to renumber lines to fit in more. Meaning, you could have commands on lines 100 through 125 but need to add something in between 107 and 108. So, you needed to renumber things.

You can use things like external events or functions to streamline the main event sheet. Some people get information overload when all of the events are in the main event sheet. Creating your own conditions, actions or entire event groups or behaviors can really slim down the main event sheet making it easier to read, debug and maintain.

Using event groups and comments also helps to organize things.

1 Like

Yes, but this seems to bug out when you have nested code. Here’s an example, I have a feature that checks to see if the player has a revive ability enabled, so I create a variable that turns on when this is true. Then further down the code there is a check to see if the player has 0 Health, if yes, Game Over. HOWEVER, there is also a secondary condition to check if the player doesn’t have the revive ability enabled. Which normally if false, should satisfy the condition, and a game over works as intended. BUT when this is actually true and the revive ability is enabled, the game SHOULD prevent the game over and the game continues as normal. But in practice, the game over happens regardless of the state of that variable EVEN when on paper it shouldn’t due to the variable being true. So my point is this, I am asking about this since the engine doesn’t seem to execute code in the supposed “Top to Bottom” order anyways when nested code is in the picture.

It does evaluate from top to bottom. It might skip over events depending on conditions but it should always be sequential.

For more precise answers it would help if you posted a screenshot of the events.

Sometimes a variable gets changed unexpected. Other times, multiple events could be true so multiple actions get triggered. A variable can be one value in one section and then another value in another section.

Sometimes events need multiple conditions like a Finite-state machine. That’s where the OR, AND and NOT conditions can be helpful.

All of the events and subevents can be hard to follow. The indentation level confuses me at time.

1 Like

Hello

In computer languages, pointers represent addresses in memory.
When you use a variable, it inherently points to an address containing the value you assigned to it.
With game engines, we normally do not use addresses (pointers) but variables.

A+
Xierra

p1varhealth=0 ------------------ resurrect things
resurrectitem=1

p1varhealth=0 ------------------- die things
resurrectitem=0

is this what you want? if so…why it shouldn’t works …or needs to be ordered?..just asking

the issue here is probably thay you need to remember to add health before check the next event…or you’re probably removing the resurrect items without giving enough “time” between events…you just need to add a “recover” event in-between…
if you put the die events on top since triggered first it gonna conflict with things below…

I already have that covered, though there are timers involved. Specifically
Line 1: Checks to see if resurrection conditions are met. If so, change Res.var to true and start the invincibility timer for 10 seconds.
Line 2: If Timer is above 0 seconds, and health reaches 0. Heal 1 hp
Line 3: If timer is 10 seconds or greater, switch off Res.var, reset and pause the timer at 0 seconds.
…fast forward to WAY down the code block in another nested group entirely…
Line ALOT: If player health reaches 0, and Res.var is false, Game over.
In theory, this should work, and there are no other variables along the chain that would change that. So other than some bizarre behavior with timer I don’t know about. I don’t know what could be causing this to happen. Also before you ask, reason for them to be this far separated is because of how I have my logic structured and organized. And the logic way down is part of a code block I call “End Game State”, and the other lines are part of the “Player Logic” code block.

Update: So the game is no longer going “game over” now, BUT now I have another problem. The timer doesn’t want to start at all leading to an unintended “God Mode” situation. Same code, just different behavior for some odd reason.

Hello @Game_Smith!

Your last post should be posted in the category “How can i do”.

A+
Xierra