
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 0.78 KB | hits: 7 | expires: Never
filling 2dArrays with another 2DArray in Lua
local T4 = {
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
};
function myFunc()
local Pieces = {}
for x = 1, 5 do
Pieces[x]={}
for y = 1, 5 do
Pieces[y][x] = T4[y][x]--the error is probably here
end
end
end
function myFunc()
local Pieces = {}
for y = 1, 5 do
Pieces[y]={}
for x = 1, 5 do
Pieces[y][x] = T4[y][x]
end
end
return Pieces
end
function copytable(t)
local copy = {}
for key,val in pairs(t) do
if type(val) == 'table' then
copy[key] = copytable(val)
else
copy[key] = val
end
end
return copy
end