What I want to do is be able to create values inside of a table's value like so:
myTable = {{"Hi",52},{},{}}
label.text = myTable[1][1]
label.Size.X = myTable[1][2]
Is there a way to do something like this in Lua?
What I want to do is be able to create values inside of a table's value like so:
myTable = {{"Hi",52},{},{}}
label.text = myTable[1][1]
label.Size.X = myTable[1][2]
Is there a way to do something like this in Lua?
This is commonly called a "nested table" e.g. tables inside tables.
Here is a quick example:-
local test = {} -- our main table
local table1 = {1,2,3}
local table2 = {4,5,6}
table.insert(test, table1)
table.insert(test, table2)
-- print the table
for i,v in pairs(test) do
print(i,v)
end
for i,v in pairs(test) do
for i2,v2 in pairs(v) do
print("table", i, "data", v2)
end
end
Then you should be able to access them like you showed in your code:-
print(test [1][1])
Hope this helps
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
I'll give that a 4/5 on rotten tomatoes.
i was in a rush :P, ile post a blog then :D