table.copy = function(t)
local u = { }
for k, v in pairs(t) do u[k] = v end
return setmetatable(u, getmetatable(t))
end
table.deepCopy = function(t)
local function _deepCopy(from ,to)
for k, v in pairs(from) do
if type(v) ~= “table” then
to[k] = v;
else
to[k] = {};
_deepCopy(v,to[k]);
end
end
return setmetatable(from, getmetatable(to))
end
local u = {}
_deepCopy(t,u)
return u
end