23 posts
Posted 10 August 2014 - 11:33 AM
I'm working on a small program, but needs to be variable the variable. (Huh? :huh:/>) This is what I mean:
"..Str2.." = {besteming = "..besteming..", minuut = "..minuut.."}
But this does not work, is there a way that I get this?
1140 posts
Location
Kaunas, Lithuania
Posted 10 August 2014 - 12:45 PM
Why do you need it? There might be another and better solution for your problem. If you want to store variables under a string or anything else just use tables:
local myTable = {}
myTable[ "this is a key" ] = "this is a value"
print( myTable[ "this is a key" ] ) -->> this is a value
656 posts
Posted 10 August 2014 - 01:11 PM
If you really need this for whatever reason, you can use:
_G[name] = value
All global values are stored in a global table, _G (Yes _G._G == _G). Therefore you can use all the features of tables on the global environment. More info can be found in the PIL, as always:
http://www.lua.org/pil/14.html .
I don't recommend using this, because then you're polluting the global environment. Use your own local table when possible.