Getting the value of a variable

Hi guys,

I have stored several variables as coordinates. Depending on where the user presses the screen, I want to execute a piece of code.

For instance I have “var1x = 250” and “var1y = 300”. I have about 40 of these variables.

Later in code when the user presses a certain image, I build a string that creates the variable name. For example “wk_x = var … wk_num … x”

When I print wk_x to the terminal, it correctly gives “var1x”. How do I make wk_x actually give 250 rather than the string value. Is there a “value” type operator?

Thanks

Adrian [import]uid: 83824 topic_id: 16725 reply_id: 316725[/import]

try tonumber()
http://developer.anscamobile.com/reference/index/tonumber
[import]uid: 71210 topic_id: 16725 reply_id: 62625[/import]

I had tried tonumber() but it only returns nil. I am not trying to convert wk_x to a number, I am trying to convert the variable name contained within the variable to a number. wk_x could be var1x, var2x, var3x, etc…

Adrian [import]uid: 83824 topic_id: 16725 reply_id: 62637[/import]

@Adrian,
I will refer you to this article http://howto.oz-apps.com/2011/09/referencing-multiple-objects-of-same.html

it is to do with arrays… sometimes we forget that we can just use arrays rather than have such complicated requirements.

varx = {}  
varx[1] = 200  
varx[2] = 250  

and so on

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16725 reply_id: 62659[/import]