Target a variable

Get help using Construct 2

Post » Fri Apr 27, 2012 6:00 pm

Hello, i have a set of variables, each are the same name with a different number in the middle

I want to say ____ = "namep1"&number&"namep2"
to target the specific variable via the number im trying to get.

ive tried str, int, etc, im not sure how to do this or if it is possible

so instead of saying if number= 1 use variable1 if number = 2 use variable 2
i just want to say "name" num
and I dont want to turn it into a text var "||||" get it?
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Fri Apr 27, 2012 6:28 pm

comoon this isnt that hard of a question, im sure every one on this forum knows how to do it XD
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Fri Apr 27, 2012 8:20 pm

You can't access global/local/instance variables with a text string. An array would be a solution in this case since a number is the only difference. You could also use the hash table plugin then you could set and get a value associated by a string. So the var is accessed with hashtable.At("namep1"&number&"namep2").
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713


Return to How do I....?

Who is online

Users browsing this forum: Lof and 4 guests