For simple tables you could do:
Some_Variable = {
[1] = "abcd",
[4] = "efgh"
};
--[[ Appending data ]]
Data_To_Append = {
[6] = "ijkl",
[3] = "mnop"
};
for i in Data_To_Append do
Some_Variable[i] = Data_To_Append[i]
end
When they get more complicated, there are recursive functions around but those are beyond me so I brute force them:
Some_Variable = {
[1] = { a=1, b=2, c=3, d=4 },
[4] = { e=2, f=3, g=4, h=5 }
};
--[[ Appending data ]]
Data_To_Append = {
[6] = { i=3, j=4, k=5, l=6 },
[3] = { m=4, n=5, o=6, p=7 }
};
for i in Data_To_Append do
Some_Variable[i] = {}
for j in Data_To_Append[i] do
Some_Variable[i][j] = Data_To_Append[i][j]
end
end
--
Not entirely sure the difference between an array and a table, but tables can be very freeform in lua.
|