Dynmaic use of a Variable

Sorry, i read almost every post here about this problem but i can’t find any working solution.
Here is my problem:

a have a global variable as structure:

and i want so change a text to the string of the “name” value

Accesssing it directly is no problem and works as expected…

now i have the “building” stored in a scene variable called “currentBuilding” an i have no idea how to get this one in there…

some of my tries…

GlobalVariableString(player.buildings.VariableString(currentBuilding).name)
GlobalVariableString["player"]["buildings"][VariableString(currentBuilding)]["name"]

and many many more, with brakets, without… i have no plan…

even if the editor shows no errors, the output ist just [object Object]

Because of this, I thing i’m not so far away but i need help…

You’re very close.
The first one, put brackets around VariableString(currentBuilding) and remove the period.
The 2nd. Surround everything inside a set of parenthesis. player is the parent and should be just player

GlobalVariableString(player.buildings[VariableString(currentBuilding)].name)
GlobalVariableString(player["buildings"][VariableString(currentBuilding)]["name"])
2 Likes

Thank you!!

i will take the first one, because it is nearer to the “original” syntax and i think it is easier to remember :slight_smile:

1 Like