mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-07 22:20:00 +00:00
functions: add function to copy tables
This commit is contained in:
Vendored
+18
@@ -35,3 +35,21 @@ function CreateGoldString(money)
|
||||
|
||||
return string
|
||||
end
|
||||
|
||||
function CopyTable(src)
|
||||
local lookup_table = {}
|
||||
local function _copy(src)
|
||||
if type(src) ~= "table" then
|
||||
return src
|
||||
elseif lookup_table[src] then
|
||||
return lookup_table[src]
|
||||
end
|
||||
local new_table = {}
|
||||
lookup_table[src] = new_table
|
||||
for index, value in pairs(src) do
|
||||
new_table[_copy(index)] = _copy(value)
|
||||
end
|
||||
return setmetatable(new_table, getmetatable(src))
|
||||
end
|
||||
return _copy(src)
|
||||
end
|
||||
Reference in New Issue
Block a user