View Single Post
06/17/14, 10:12 AM   #3
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by ingeniousclown View Post
This already exists as a global function implemented by ZO:
lua Code:
  1. function ZO_DeepTableCopy(source, dest)
  2.     dest = dest or {}
  3.    
  4.     for k, v in pairs(source) do
  5.         if type(v) == "table" then
  6.             dest[k] = ZO_DeepTableCopy(v)
  7.         else
  8.             dest[k] = v
  9.         end
  10.     end
  11.    
  12.     return dest
  13. end

This excludes metatables, however, and at a glance, it looks like it will crash on any circular reference.
Since I only have data I want to hand out data from my Saved Vars without having any side effects this is ideal.
  Reply With Quote