Code: Select all
table = {"varname"}
varname = 5
print (_G[table[1]])
Does anyone know why this is? Any alternative way to access variables via strings?
Thanks!
Code: Select all
table = {"varname"}
varname = 5
print (_G[table[1]])
Code: Select all
print(table["varname"])
Code: Select all
table = {"varname"}
varname = 5
print (table["varname"])
Code: Select all
table = {"varname"}
table["varname"] = 5
print (table["varname"])
Code: Select all
test_array = {}
test_array["test"] = 1
print (test_array["test"])
Code: Select all
module_corner_1_walls = {
1,1,1,1,1,1,1,
1,1,1,1,1,1,1,
1,1,1,1,1,1,1,
2,0,0,0,1,1,1,
1,1,1,0,1,1,1,
1,1,1,0,1,1,1,
1,1,1,2,1,1,1
}
Code: Select all
corner_walls = {"module_corner_1_walls", "module_corner_2_walls", "module_corner_3_walls" etc....}
? This prints 1 as it's supposed. btw. you can leave out the brackets, the above code is equivalent to:Scotty wrote:Global error.Code: Select all
test_array = {} test_array["test"] = 1 print (test_array["test"])
Code: Select all
test_array = {}
test_array.test = 1
print(test_array.test)