Structure Variable transforms to an Array Variable

when i try adding an existing variable to an structure variable, the structure variable transforms to an array variable

how do i make the structure variable not transform to an array variable?

Structures and arrays works the same in GD. At least it’s your writing them with events. There’s no problem.

Your using an action to add a variable to an array. Structures just need to be assigned a value.

2 Likes

what do you mean by that?

@Keith_1357 means that you don’t need a specific action to add a variable into a Structure variable. Just put like any other variable. Look my example:

I just have this structure variable:

In events when “a” is released i put to “change” a variable that don’t exist inside of my Structure variable:

Using Debbuger in preview Gdevelop creates that variable after I released the “a” button:
image

1 Like

oh, i didnt know that, thanks!

there is a little problem, what i am trying to add is an structure variable inside another structure variable. this didnt work:

EDIT: NVM THE ADDED OBJECT WAS IN THE BOTTOM OF THE LIST

It works but not in the way you probably expected.

When I tested
“child.tom” it becomes “child tom”
Spaces are not recommended.

Quotes aren’t really needed unless you’re adding a variable that’s a string to the child name. Or a number using ToString()
game[“level’” + VariableString(lvl)]

It can be simple or a complex formula. I would stick with simple. Simple is good. I’m just saying it’s versatile.

Unfortunately, the autocomplete syntax thing doesn’t show in every situation so it becomes less “code free”. It’s getting closer though.

These are the same
Fruit.apple.size
Fruit[“apple”].size

name=“apple”
Fruit[VariableString(name)].size

It can be as simple or complex as you need. Structure or array or array of structures or arrays within structures. It can get confusing.