I have 14 variables with different numbers (like an array), since I didn’t find a way to create arrays. They are called pris0, pris1, pris3 etc. They all contain a unique text string. I made them like this:
Change the text of scene variable pris0: Set to “ball”
Change the text of scene variable pris1: Set to “hammer”
Change the text of scene variable pris2: Set to “phone”
Now I want to show the content of the variable prisX (pris0, pris1, pris2 etc) in a textobject, but I can only show the string priX not the text string in the variable prisX.
I solved it the “ugly way” by creating a bunch of if events…
if Leftshelf.Animation() is 1 change the text of GetMoney to pris1()
if Leftshelf.Animation() is 2 change the text of GetMoney to pris2()
if Leftshelf.Animation() is 3 change the text of GetMoney to pris3()
But if anyone has a better solution please show me!
Use structures. A structure is a variable type like string and number for containing other variables. Let’s say you create one named arrayNames. You can then add children like name1, name2… Etc, set the variable index to 0 and then use a repeat event with “get number of children of a structure”,
and for each iteration add 1 to index and access the value using Variable (arrayNames[Variable(index)]).