Creating a Flexible varible name?

Hey guys i want to call a static variable name, with a flexible variable code. Heres what i mean. (I apologise for the bad phrasing)

var Slot1 = "";
var Slot2 = "";
var X = 0;

Function onGUI (){

if click button
{
X = 1;
Slot(X) = "Blah blah blah"
}
}

So, therefore, if X = 2, i would transform Slot2 instead.

Seems like something basic, but Slot(X), isnt working, and im missing something here. What suffix do i add to ‘Slot’, for it to recognise X?

Thankyou!

1 Answer

1

It’s hard to understand what you’re getting at, but I get the impression that you’d want to use an array. When you have more than one thing, you use an array of some kind (or List, or possibly Dictionary).

You never want to use multiple variables like that. As I said, use an array. If you don't understand arrays, you really need to look them up since it's a fundamental part of programming.

Alright thanks