Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a table inside a table?

Asked by
zulyrus 10
5 years ago

Is there a way to not repeat

local arg = {} local arg2 = {} local arg3 = {} ... ...

?

local set = {}
local arg = {}
local arg2 = {}
local arg3 = {}
local num = 0
msg = msg:sub(#ms.StartCommand+1):lower()
for w in msg:gmatch("%S+") do
    num = num + 1
    for a in w:gmatch("([^,]+)") do
    if num == 1 then
        table.insert(arg,#arg+1,a)
    elseif num == 2 then
        table.insert(arg2,#arg2+1,a)
    elseif num == 3 then
        table.insert(arg3,#arg3+1,a)
    end
end
0
local Table = { {} } SuperSamyGamer 316 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

If you want to make a table inside of a table when it is defined, try this.

local table1 = {
    table2 = {},
}

If you want to insert a table inside another table after it has been defined, try this.

local table1 = {}
local table2 = {}
table.insert(table1, table2) -- 'table' is a reserved name

Tables can hold almost any value... including more tables.

Ad

Answer this question