View Single Post
11/28/14, 09:42 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Yes, it is exactly that easy as you say.

Just add some flag to the saved variables, so you can check if variables are updated already. Something like:

Lua Code:
  1. local newDefaults = {
  2.     internalVersion = 1,
  3.     key1 = value1,
  4.     ...
  5. }
  6.  
  7. MYADDON.savedVariables = ZO_SavedVars:New(...) --here should be correct arguments to the function
  8.  
  9. local currentVersion = MYADDON.savedVariables.internalVersion or 0
  10.  
  11. if currentVersion < newDefaults.internalVersion then
  12.     for k, v in pairs(newDefaults) do
  13.         MYADDON.savedVariables[k] = v
  14.     end
  15. end

Last edited by Garkin : 11/28/14 at 09:44 PM.
  Reply With Quote