Anonymous

Module:Shared: Difference between revisions

From Melvor Idle
Fixed failed copy+paste
No edit summary
(Fixed failed copy+paste)
Line 237: Line 237:
-- or any other read-only variable
-- or any other read-only variable
-- Stolen from https://gist.github.com/tylerneylon/81333721109155b2d244
-- Stolen from https://gist.github.com/tylerneylon/81333721109155b2d244
function p.clone(orig)
function p.clone(obj)
     if type(obj) ~= 'table' then return obj end
     if type(obj) ~= 'table' then return obj end
     local res = {}
     local res = {}
     for k, v in pairs(obj) do res[clone(k)] = clone(v) end
     for k, v in pairs(obj) do res[p.clone(k)] = p.clone(v) end
     return res
     return res
end
end
   
   
return p
return p