Hello, I’m trying to print a table using string as table identifier. I know the best way is to directly call the table using itself as a variable, but I need to know if what I want to achieve is possible.
Script:
-- first version
local tab1 = {3,1,5}
local tab2 = {5,3,1}
local tab3 = {1,5,3}
local selected = "tab3" -- must be string // totable()? like tostring()
print(table.concat(selected,", "))
-- other version
local Tb_1 = {"S1","S2","S3"} -- {"S1","S2","S3","S4"}
local Tb_2 = {"V1","V2","V3"}
table.insert("Tb_1","S4") -- don't work(reason string identifier of table)
print(table.concat(Tb_1,", ")) -- works fine
Output expected:
-- first version
> 1, 5, 3
-- other version
> S1, S2, S3, S4
Output reality:
-- first version
invalid argument #1 to 'concat' (table expected, got string)
-- other version
invalid argument #1 to 'insert' (table expected, got string)
Thanks for any feedback.