Mishaho
(deadcandle)
September 11, 2021, 1:34pm
1
Quick question, how exactly would I insert the table below inside of an existing table?
[1] = {
[player1.Name] = {
item1 = 0,
item2 = 0
},
[player2.Name] = {
item1 = 0,
item2 = 0
}
}
ItsSovxy
(Sovxy)
September 11, 2021, 1:39pm
2
You would want to do something like this:
table.insert(TableName,{--[[Info]]})
Mishaho
(deadcandle)
September 11, 2021, 1:39pm
3
I tried this:
table.insert(duels,
{
[1] = {
[player1.Name] = {
item1 = 0,
item2 = 0
},
[player2.Name] = {
item1 = 0,
item2 = 0
}
}
}
)
D0RYU
(nici)
September 11, 2021, 1:40pm
4
local Table1 = {}
local Table2 = {
{
[player1.Name] = {
item1 = 0,
item2 = 0
},
[player2.Name] = {
item1 = 0,
item2 = 0
}
}
}
table.insert(Table1, Table2[1])
is this what you want?
ItsSovxy
(Sovxy)
September 11, 2021, 1:41pm
5
Each Individual table would need to be inserted within the existing table, In other words your creating a dictionary where your adding a table within a table if you understand what I mean.
Mishaho
(deadcandle)
September 11, 2021, 1:42pm
6
This is what I want
table.insert(duels,
[1] = {
[player1.Name] = {
item1 = 0,
item2 = 0
},
[player2.Name] = {
item1 = 0,
item2 = 0
}
}
)
D0RYU
(nici)
September 11, 2021, 1:43pm
8
table.insert(duels, {
[player1.Name] = {
item1 = 0,
item2 = 0
},
[player2.Name] = {
item1 = 0,
item2 = 0
}
}
)
you have to do this
Mishaho
(deadcandle)
September 11, 2021, 1:44pm
9
Can I still get it with [1] after that
Im assuming you want a dictionary?
largetable[1] = {
[player1.Name] = {
item1 = 0,
item2 = 0
},
[player2.Name] = {
item1 = 0,
item2 = 0
}
}
D0RYU
(nici)
September 11, 2021, 1:44pm
11
what do you need the [1] for?
is the table you are inserting part of another table?
Mishaho
(deadcandle)
September 11, 2021, 1:45pm
12
Yes it is a part of another table
D0RYU
(nici)
September 11, 2021, 1:45pm
13
table.insert(duels, OtherTable[1])
Mishaho is this what you were looking for?
Nonaz_jr
(Nonaz_jr)
September 11, 2021, 1:47pm
15
You can just directly assign your sub-table to an index in your parent table.
local myTable = {}
local mySubTable = { <stuff> }
myTable[1] = mySubTable
Note that it puts a reference to your subtable there, not a copy of the subtable.
ItsSovxy
(Sovxy)
September 11, 2021, 1:47pm
16
local duels = {
[1] = {
}
}
duels[1][Player1.Name] = table.create(2)
Player1.item1 = 0
Player1.item2 = 0
local Player1 = table.insert(duels[1],duels[1][Player1.Name])
1 Like
ItsSovxy
(Sovxy)
September 11, 2021, 1:50pm
17
Sorry about that but here’s an example:
local duels = {
[1] = {}
}
-- Creating a player's Info
duels[1][Player1.Name] = table.create(2)
duels[1][Player1.Name].item1 = 0
duels[1][Player1.Name].item2 = 0
table.insert(duels[1],duels[1][Player1.Name])
Mishaho
(deadcandle)
September 11, 2021, 1:50pm
18
this worked in the way i wanted it to