How to see extension scene variables in debugger?

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

as title says, how to see extension scene variables?

activating advanced mode (the little lightning icon) shows many stuffs but not scene variables from extension

I’m not sure that you can. It would definitely be nice.

You can display the values of the variables in the console.

You can also add a parameter for a text object that you place in the scene and change it’s text from within the extension. This is nice because you don’t have to look at the debugger.

Sometimes, it’s the value that you want to check. Other times, it’s the value at a specific location. The console is good for that.

For arrays and structures, you can convert the variable to JSON first.

I was recently having problems. So, I added a text object as a parameter to my function and then used for each child to add the values to the text object instead of using the JSON format.

You can pass values back as properties or return values through an expression.

it would be nice yes

That’s one of the setbacks of using temporary local variables. They don’t exist except for that little block of events. I don’t think they’ll ever add a way to see local variables. They should for all of the various extension and behavior variables, properties and other things like custom objects. I think you can already for some. IDK.

I like a visible, realtime view. So, I tend to add a text object.

yup me too! i actually once created something similar to imgui inside gdevelop and you could easily pass it any information and it would display it

About these local extension variables, i suppose they are shared between all functions of the extension which could be a problem if a function calls an another function sharing the same local variables.

Unless perhaps to declare the variables inside each function.

Somebody can confirm or infirm that i said?

Thanks

Extensions can have properties, scene variables and global variables.

These are shared internally with the entire extension.

Not to be confused with local variables that I mentioned which can be used anywhere. They only exist in the event and subevents of the event they were declared. They can be used anywhere. Scenes or functions.

https://wiki.gdevelop.io/gdevelop5/all-features/variables/local-variables/

Thank you very much Keith.
But I want to make sure I understand correctly.
Am I correct in saying that there will be a conflict at the level of local variables (called scene variables) if in an extension, I use a function which calls another function and for which would use the same scene variables?
Not very easy to explain but I hope I have been clear.
In my opinion, without having tested too much, I think there will inevitably be a conflict.

On the other hand, I think it should work if I use “Declare…” inside the 2 functions, even if I use the same variable names as the local so-called scene variables.
Because the computer memory will be different for this temporary reservation of variables et these last variables will be priority.

Can you Keith confirm this last point?

EDIT: in the same event, of course

Thanks

Let’s be clear on the names. There are Local Variables that exist only during the events and subevents that they were declared in. They are the only variables referred to as local. Unlike, scene or global variables.

There are scene and global variables that exist in scenes or globally.

There are extension scene and extension global variables that are declared for the entire extension not for any particular function. These are shared internally with everything inside the extension.

If you change the value of an extension variable, that value will be used the next time the variable is used. No matter if it’s in the same function or a different function.

You can use a local variable. Those can be used anywhere. The local variable is temporary and gets removed after the subsequent event and subevents that it is declared in ends.

You can use multiple local variables with the same name in different parts of the same function or different functions. Because each time, the variables get created and then destroyed.

If the value of an extension variable isn’t important in the long term. Then you can reuse them for similar tasks. If the information needs to be retained beyond the functions then it would be best to use unique variables.

You can always prefix variable names if it helps. Add a few characters before the variable name to make it clear what the variable contains or where it is used. Instead of index, it could be SavingIndex or LoadingIndex. Structures can also be used to organize the variables.

You can have a combination of different types of variables. Each one has their own benefits and limitations.

Thanks Keith.

I think to use different names for each function of the extension (with prefix). It’s more safe, for me.

Thanks again

Whatever works for you. The key is to use short, descriptive variable names. That way, it will make sense today and a few months from down. If needed, you can also add comments and event group descriptions.

On the other hand, and if I understood correctly, it is not possible to declare variables that are only local to a given function.
As can be done in programming languages.

By example:
Function WordInString(sourcestring: string)
Int: counter
…

The variable counter will be here local for the function WordInString. So invisible for other functions or calling program.

Be careful with the terminology. I know every programming language has their own terms.

A Local Variable in GD is a variable defined in the event sheet. It only exists during the event and any subevents. It’s removed immediately afterwards.

In the picture below. R and C are local veriables. They’re defined within the event sheet. No where else. (Row and Column)

There aren’t any variables that are specific to a single function.

There are parameters but they’re just used to pass values between either the scene or other functions.

Ok! This answers very well to all my questions.

Thank a lot Keith.