Calling a variable with "n" + randomnumber?

Basically I have a bunch of scene variables set up like so:

“n1” = 5
“n2” = 10
“n3” = 20

There’s lots more than just the three, but you get the idea.

I also have another variable to hold number totals I’ll be adding to:

“Total” = 0

Later on I’m generating a random number, and would like to retrieve the value of of one of the ‘n’ variables. For example, given the above example I’d generate something between a 1 and 3. If 3 is generated, I’d like to retrieve the value of n3 (which is 20) and add it to Total.

But I can’t figure out a way to call that variable without typing it in quotes (or writing tons of conditions which really isn’t practical.) Is there a way to put together that variable name dynamically? Something like:

Change the scene variable Total: add Variable(“n” + Variable(RandomNumber))

That doesn’t work of course, but hopefully conveys the idea.

you have to use a variable structure for this. for example:

and the event for this:


Thank you! Exactly what I needed.

1 Like