String + Variable as variable name?

I'm trying to create a system in which I create a new variable every time a function is called. For example, click something once and a variable called 'test1' is created. Click a second time and 'test2' is created.

I've come up with this so far, but it is not working properly:

Hash["test" + stepNumber] = int();

The only bit wrong with your code is the = int(); bit

Swap that with a normal assignment and it should work fine


Hash["test" + stepNumber] = 5;

This is, however, assuming Hash is a Hashtable variable of some kind (which it does sound like)

Use String.Format to combine the two:

var fullStep : String;
var stepNumber : int = 2;
fullStep = String.Format("test{0}",  stepNumber);
Debug.Log(fullStep); // prints test2
Hash(fullStep) = stepNumber;