Displaying a variable's name when set as another variable

Hi all, I’m having trouble printing a variable that I set as another variable. Here’s an example:

*set Speed 25
*set difficultycheck Speed

I need to find a way to use the “difficultycheck” variable to display the value for speed (25) and also the word Speed.

It’s for a large gosub routine with multiple stats so I can’t just print the word. I can use a ton of if statements but that’s messy.

Hmmm, you could use multireplace?

For example, say for a Speed increase, you set difficulty check to 1, Strength increase, set it to 2, Dexterity increase, set it to 3, and then the following should print out {whatever was increased}: {value}. and you can just add more stats on.

@{difficultycheck Speed: ${speed}|Strength: ${strength}|{Dexterity: ${dexterity}}

Its still… an if in a way, but its more concise?

The problem with that method is I’m going to have different difficulties to the same stat all the time, I plan to use this subclass hundreds of times and hope to only have to set 2 variables. I can set 3 if need be but was wondering if there was a solution to my plan to do it with 2

To access a value by reference use curly braces.

This will print Speed.


And this will print the value 25. (Notice the extra pair of curly braces.)


You can use it in expressions as well.

*set myVar (42 + {difficultycheck})
*set {difficultycheck} %+5
1 Like

If that works out then that’s exactly what I needed, thank you!

1 Like

Hmm I’m actually hitting an issue, in that example both ${difficultycheck} and ${{difficultycheck}} are returning with 25. I can’t figure out how to get it to function as Speed instead.

Okay! I found an issue and found the solution. So both ${diffucltycheck} and ${{difficultycheck}} were returning 25 instead of Speed, and that’s because of how I set it, it was never a string. I used:

*set Speed 25
*set difficultycheck Speed

What I need to do instead is:

*set Speed 25
*set difficultycheck “Speed”

Hope this helps anyone in the future!

1 Like