View Single Post
11/29/14, 01:10 AM   #3
Argusus
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 120
Originally Posted by Garkin View Post
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
thank you very much
  Reply With Quote