Advertisement
Guest User

initair

a guest
Oct 4th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. --initScript()-----------------------------------
  2. -- Put your Lua functions here. --
  3. -- --
  4. -- Note that you can also use external Scripts --
  5. -------------------------------------------------
  6.  
  7. function deepcopy(orig)
  8. local orig_type = type(orig)
  9. local copy
  10. if orig_type == 'table' then
  11. copy = {}
  12. for orig_key, orig_value in next, orig, nil do
  13. copy[deepcopy(orig_key)] = deepcopy(orig_value)
  14. end
  15. setmetatable(copy, deepcopy(getmetatable(orig)))
  16. else -- number, string, boolean, etc
  17. copy = orig
  18. end
  19. return copy
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement