[Solved] Using a variable as a part of another variable

Hello ~

These are a few of my events.

What I am trying to do is replace numbers in Global variable(structure)

GlobalVariable(exp.11)

to a variable like this.

GlobalVariable(exp.GlobalVariable(stage))

So that I don’t need to write too many events for every stage.
But it doesn’t work.
Is there any way to make these events simple??



I found out I can put a variable in another variable(array) like this.

I guess it is working because of brackets ?!

But I want to know how do I do this with structure variable.

Because my stage numbers are 0~1000+ and it is not efficient to make 1000 of arrays.

Thank you!

Maybe, change the text to:
ToString(GlobalVariable(exp[GlobalVariable(stage)]))

2 Likes

Here are a few ways to write a structure variable.

1 Like

It works!!
ohh Why couldn’t I think of this!!
Thank you!!! :blush: :blush: :blush:

Wow!!
This is so useful! Awesome!
Thank you so much!


Can I ask you one more thing??

What should I do if a variable is a string?

ex) Variable(Hero) = aaa OR bbb OR ccc

All of these below do not work.

bestScore[“Variable(Hero)”][“Stage1”]

bestScore[Variable(Hero)][“Stage1”]

bestScore[ToString(Variable(Hero))][“Stage1”]

Can I make this work?

If the variable is a string, you wouldn’t need the ToSting() and you would change the Variable to VariableString(). You could add the text to a string in quotes or just use the string. Although, “best practice” is to use variable or structure names of letters or letters followed by numbers. Even when in text form, a number alone looks like an array and isn’t as descriptive in the debugger. I would use “player1” or “player” + VariableString(player)

image

bestScore[“Variable(Hero)”][“Stage1”]  -->  bestScore[VariableString(Hero)][“Stage1”]

bestScore[Variable(Hero)][“Stage1”] --> bestScore[VariableString(Hero)][“Stage1”]

bestScore[ToString(Variable(Hero))][“Stage1”]  --> bestScore[VariableString(Hero)][“Stage1”]

1 Like

Woooow!!!

It works perfectly now!!

Thank you so much!!!

Now I can make the super long events very simple. hehe :blush: :blush: :blush: :blush:

1 Like