Structures Question

Hey Gdevs!,

I cant find a “useful” Tutorial for Structures being displayed as a Text.

If the Player, loots an Item this item should be added to the Structure with the Value.
after that the second loot and than the Third. i want to display the full Structure without knowing, wich item he picked first. the first he picks should be displayed first, the second and so on, like a inventory.

how is this possible ?

Thanks!

edit: This is probably much more than you need but it gives an introduction to the various methods.

I’m not sure how to do it with a structure without adding a child name with a number in it. This is doing it with an array. It can be an array of structures. You can’t use for each child because that only works for scene variables. You could use JSON to make a copy of an object structure and then use for each child on that structure.

The following would work for a structure but you might as well use an array because this would require adding a number to a string and it would be difficult to maintain if you removed items.

This would copy the object variable to a temp variable using JSON and use for each child. child would be the value and childname the child’s name.

1 Like

Thank you mate! you are great

1 Like

You’re welcome. I don’t know why I read your question as if you wanted an object structure. I guess I saw Player and I thought of a Player object. I hope that didn’t confuse you.

You could definitely use for each child with a scene variable. Numerous people have asked for the for each child to be expanded to work on global and object variables.

If you’re using scene variables then my examples still apply. It’s only the scope that changes. You can use JSON to copy a global variable to a scene one just as easily as an object. Although, I would still do it sparingly for efficiency sake.

I wish you well. Variables are one of the least talked about aspects but require the most typing.

1 Like