View Single Post
08/05/15, 02:42 PM   #8
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Reading the other posts I now realize although I offered information, I didn't actually offer a solution:

Warning: Spoiler


One other thing to note is that in these:
Lua Code:
  1. characterSpecificSavedVars = ZO_SavedVars:New(savedVariableTable, version , nil, defaults)
  2. AccountWideSavedVars = ZO_SavedVars:NewAccountWide(savedVariableTable, version, nil, defaults)
You will most likely will NOT want to use your addon version number. The reason is because every time you increase the version number it would wipe out the saved variable table (it does that automatically when the version number increases). I usually define two version numbers in my addon like:
Lua Code:
  1. local CODE_VERSION = 2.3
  2. local SAVED_VAR_VERSION = 1.2
Then just use them each wherever appropriate.
Lua Code:
  1. characterSpecificSavedVars = ZO_SavedVars:New(savedVariableTable, SAVED_VAR_VERSION, nil, defaults)
  2. AccountWideSavedVars = ZO_SavedVars:NewAccountWide(savedVariableTable, SAVED_VAR_VERSION, nil, defaults)

As the addon version number increases I just change the CODE_VERSION. If the saved variables need to be wiped due to addon changes, then increase the SAVED_VAR_VERSION...and don't define them right next to each other (one line right after another), you'll end up accidently changing the wrong one by mistake and wiping everyone's saved vars
  Reply With Quote