[Solved] Dynamically Switching Variables

How do I…

Sorry to be back asking for help so soon. :smiley: So, I’m trying to build a UI element with sliders that will adjust certain variables. However, I want the exact variables they adjust to change dynamically. So I tried to create three variables that stores the names of the randomly chosen ones for the sliders, hoping that I can plug them in for the slot for the variable name. Like this:

Difficulty1

However, as you can see, the game won’t let me. Is there any way I can work around this?
Also, is there any way I can draw randomly chosen items from an array without repeats? And any way to make a script wait until a button is pressed?

Thanks.

Put the variable and it’s value into a structure. Yes, there’ll be an extra layer of variable, but it will also give you the flexibility you’re after. So you’d end up with:

2*GlobalVariable(myStruct[GlobalVariableString(Balance1)])

Will try. Is it possible to pick something from a structure at random, like a list?

Depends on how you name the keys. If you name them so they contain a sequential numbering, then yes (like “Tree1”, “Tree2” etc). But if they are just strings, then no.

1 Like

you can either do what @MrMen said by creating child variables,
or you could install the extension “extended variable support” which can let you call/set/check variables dynamically with a couple of other cool features,

Implemented the structure, it works great now. Thanks.