View Single Post
01/25/16, 06:45 AM   #4
coolmodi
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 47
I'm pretty much still a noob in programming, but as I understand it LUA will always reference tables, but "copy" other values.

Lua Code:
  1. x = "asfaf"
  2. y = {"af","sdgsd"}
  3.  
  4. z = x --z will be "asfaf"
  5. w = y --w is only a reference to the table

There's also something called metatables that can change the behavior of tables, ZO_DeepTableCopy ignores them, maybe that messes something up. In GroupDamage I used a custom deepcopy function because I didn't know the ZOS one existed and only because of that even stumbled over this topic. Maybe that's worth a try?

Lua Code:
  1. local function deepcopy(orig)
  2.     local orig_type = type(orig)
  3.     local copy
  4.     if orig_type == 'table' then
  5.         copy = {}
  6.         for orig_key, orig_value in next, orig, nil do
  7.             copy[deepcopy(orig_key)] = deepcopy(orig_value)
  8.         end
  9.         setmetatable(copy, deepcopy(getmetatable(orig)))
  10.     else -- number, string, boolean, etc
  11.         copy = orig
  12.     end
  13.     return copy
  14. end

But again, I'm really no pro here, and maybe the error is somewhat completely different that we both just don't see
  Reply With Quote