View Single Post
03/08/21, 02:14 AM   #8
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Originally Posted by Shadowfen View Post
I use a function from my LibSFUtils library, called LibSFUtils.defaultMissing(). You pass in the saved variable table and the defaults table and it recurses down the defaults table looking for values that are not in the saved variable table. When a variable:value is found to be missing, it is put into the saved variable table. If there is a variable already in the saved variable table, then its value is left untouched.

My typical usage is:
Code:
    local save = ZO_SavedVars:NewAccountWide(savedvar, sv_version, nil, defaults)
    LibSFUtils.defaultMissing(savedvar, defaults)  -- adds in new variables in old savevars
Ist't the standard defaults of ZO_SavedVars doing the same?
I mean if I just add an entry to a default table which is used in my SavedVars already it will be added if it did not exist (was nil in the disk file) before upon login/reloadui.

Did test this today (PTS), works fine without any manual effort or funcitons to check and do code, but I'm pretty sure it always worked that way.
  Reply With Quote