Using variable names to replace parts of an expression

okay i have a very complex question…
how can i achieve using variable names (specifically global variable names) in place of information in an expression?


like this. i want to use what’s currently equipped in slot 1, as its name in the item information variables, then using a child of the structure that was named from slot 1, (called heal). i dont wanna have to copy and paste every value for each item, in each slot as thats… very redundant.

Check out the GDevelop wiki on accessing child variables in structure. I think it’ll answer your question.

1 Like

thank you :slight_smile:

if anyone wants to know, this is what i used

GlobalVariable(ITEM_VALUES.HEALING[GlobalVariableString(GLOBAL_SAVED.Inventory.Slot1)].heal)

Heads up, you don’t need to use GlobalVariable or GlobalVariableString with the more recent versions of GDevelop. It’ll figure out the variable you’re referring to.

So instead you can use ITEM_VALUES.HEALING[GLOBAL_SAVED.Inventory.Slot1].heal

this is much easier on the eyes. thank you!