A variable variable

HI,

is there a way in Lua of referring to a variable using another variable.

This can be achieved in most languages, php for instance uses $$x to make $x the name of the vraiable.

Thanks for any help. [import]uid: 7830 topic_id: 8327 reply_id: 308327[/import]

Sort of. Not in the same sense php does it, but if you have a table with stuff stored in it, you can use a variable to index into that table:

[code]
table = {}
table[1] = “word”
table[2] = “value”
table[3] = “text”

local i = 2
print(table[i])
[/code] [import]uid: 12108 topic_id: 8327 reply_id: 29835[/import]

OK, thanks for that.

Can the i be replaced by a string rather than an integer, as in your example.

Thanks for the help. [import]uid: 7830 topic_id: 8327 reply_id: 29863[/import]

[lua]table[“something”] = “whatever”

local amigo = “something”

print(table[amigo]) – “whatever”[/lua] [import]uid: 6645 topic_id: 8327 reply_id: 29941[/import]