Advertisement
Dramiel

RIFT table copy

Oct 18th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.36 KB | None | 0 0
  1. local tcopy = nil;
  2. tcopy = function(from, to)
  3.     for k, v in pairs(from) do
  4.         if (type(v) == "table") then
  5.             local dest = to[k];
  6.            
  7.             if (type(dest) ~= "table") then
  8.                 dest = {};
  9.                 to[k] = dest;
  10.             end
  11.            
  12.             tcopy(v, dest);
  13.         else
  14.             to[k] = v;
  15.         end
  16.     end
  17. end
  18.  
  19. tclone = function(t)
  20.     local result = {};
  21.  
  22.     tcopy(t, {});
  23.  
  24.     return result;
  25. end
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement