create table.deep_copy
This commit is contained in:
parent
a2bf2bc1a1
commit
c5033dc6ff
@ -56,9 +56,19 @@ end
|
|||||||
function table.copy(t)
|
function table.copy(t)
|
||||||
local copied = {}
|
local copied = {}
|
||||||
|
|
||||||
|
for k, v in pairs(t) do
|
||||||
|
copied[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
return copied
|
||||||
|
end
|
||||||
|
|
||||||
|
function table.deep_copy(t)
|
||||||
|
local copied = {}
|
||||||
|
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
copied[k] = table.copy(v)
|
copied[k] = table.deep_copy(v)
|
||||||
else
|
else
|
||||||
copied[k] = v
|
copied[k] = v
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user