Thread Tools Display Modes
11/28/14, 02:10 PM   #1
Argusus
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 120
adding new saved variables

Is there a way to add a new "default" saved var to my existing variables without having to change the version number and clear out current user's saved var file?

is it easy as just adding the new value to my code on addon load?

Code:
MYADDON.savedVariables.AutoSaveChanges = 0
  Reply With Quote
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
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

ESOUI » AddOns » AddOn Help/Support » adding new saved variables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off