I am wanting to create a table that is formatted like so:
local Items = {
[1] = {
["Donut"] = {
[1] = "Sprinkles";
[2] = "Something";
}
};
[2] = {
["Cookie"] = {
[1] = "Chocolate Chip"
}
};
-- ... and so on until [3] max items
}
It starts off as a normal table local Items = {}
and will need to look like the given example using a script, e.g. using table.insert() and other functions
But at the moment I’m unsure of how I can get it to look like that. Any ideas?
Have you tried
local Items = {}
table.insert(Items,
["Donut"] = {
[1] = "Sprinkles",
[2] = "Something"
}
)
print(Items.Donut.1)
Hope this will help:
local Table = {} --Your table
Table.Donut = {} --Create the donut inside of Table(Not using table.Insert() so you can give it a name and not have number listing).
table.insert(Table.Donut, "Sprinkles")-- Adding things inside of Donut(Using table.Insert() to give numbering effect)
table.insert(Table.Donut, "Something")
print(Table)--printing the output
--[[
output should look like this:
▼ {
["Donut"] = ▼ {
[1] = "Sprinkles"
}
}
]]