[Solved] Structure variable

Hello everyone!!
if I create a structure such as
“dog cat. 500 variables”
my structure will have 500 variables with leathers I can change things … now … if at some point I have to reset all 500 variables that are inside the “dog cat” structure or set them all with another identical value. .like eg “10” in gdevelop … it works if I write
globalvariable (dog.gatto) = “10” ?? the system puts me all 500 to 10 automatically ?? or do I have to do one by one ???

thank you in advance!!!

No, it will just set the one variable.

If you want to reset all the children of a structure variable to the same value (it has to be a scene variable, not a global), use the For each child variable event :

image

Like this :

2 Likes

okok tnk… i need for global…

If it has to be for global, you could copy the global variable to a scene variable, apply the changes tot he scene variable and copy back to the global variable. Not ideal, but it’s a way around it.

Another way around it is to use the reference extension: it transforms a scene variable into a “fake variable” that pipes all reads and writes into a global one. That way, you can link a scene variable to a global one, and use it in a for each event. The scene variable will not do any copy, but simply redirect the reads to the global one allowing to loop over the global one without complex copying back and forth.

1 Like

It’s interesting. What is the extansion name ? (i searched using “variable” or “reference” word but I can’t find it)

Thanks,
J

Thank you!! I find what you say very interesting … would you like to give an example ??? I ask you for my perfect understanding …

It’s a community extension :wink:

I cannot, I am on my phone, not my PC, right now. I barely have the time to write this post, so I do not have the time to create a full example of the extension. Luckily, it is pretty self explanatory - just throw your global variable and a scene variable into the reference action, and use the scene variable as if it was your global one.

HI Arthuro555,
can you please help me to understand if there is a page with all community extension. I have searched on GD Wiki, Google but I’m not able to find it.

Thanks,
J

Gif that shows how to enable community extensions

wow, thanks a lot.
Bye,
J

when you can… make your example for me like that please???