the real problem traversing the SavedVars is that the actual data is stored in a metatable.
i use the following (rather long) snipped to auto generate default get/set functions for my SavedVars.
Lua Code:
local function Factory( input, output, pre )
if pre ~= "" then
pre = pre .. "."
end
for k, v in pairs( input ) do
if k ~= "version" and type( v ) ~= "function" then
output[ k ] = {}
if type( v ) == "table" then
Factory( v, output[ k ] , pre..k )
else
output[ k ][ "get" ] = function()
return input[ k ]
end
output[ k ][ "set" ] = function( new )
local old = input[ k ]
input[ k ] = new
CM:FireCallbacks( "VariableChanged", Addon.id, pre..k, old, new )
end
end
end
end
end
local SavedVars, Accessors = ZO_SavedVars:New( Addon.id, Addon.SavedVarsVersion, nil, Addon.Defaults, nil ), {}
if t and type( SavedVars ) == "table" then
local meta = getmetatable( SavedVars )
if meta and meta.__index and type( meta.__index ) == "table" then
Factory( meta.__index, Accessors, "" )
end
end