I want to create a table that can be called like table1[table2][table3][name] = value
is that possible? And if its possible, i can serialize and unsrialize that table(because i want to store in a file)?
Table in a Table
Started by FuuuAInfiniteLoop(F.A.I.L), Mar 18 2013 08:45 AM
3 replies to this topic
#1
Posted 18 March 2013 - 08:45 AM
#2
Posted 18 March 2013 - 08:48 AM
Yes and yes. Just make sure that you have defined the table within your table before trying to add values to it.
Or a cleaner version:
local myTable = {}
myTable[1] = {}
myTable[2] = {}
myTable[1][1] = "Hello!"
myTable[2][1] = "Test!"
Or a cleaner version:
local myTable = {
["table1"] = {1,2,3,"HELLO!"};
["table2"] = {3,2,1,"Test!!!"};
[3] = {"whatever", 1,2,3};
}
print(myTable.table1[1]) --Outputs 1
print(myTable.table2[4]) --Outputs "Test!!!"
print(myTable[3][1]) --Outputs "whatever"
#3
Posted 18 March 2013 - 08:52 AM
thanks
#4
Posted 18 March 2013 - 09:07 AM
table = {
["someTable"] = {
{text = "something here"},
{text = "more things"},
{text = "last thing"}
},
["someOtherTable"] = {
{text = "lols"}
}
}
}
for k,v in pairs(table["someTable"]) do
print(v.text)
end
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











