View Single Post
03/07/21, 07:15 AM   #1
Saenic
 
Saenic's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 7
Adding new option while keeping SavedVars

Heya,

I've got an addon which uses SavedVariables. Now I want to add a new variable to the SavedVars and have the users keep their old settings.

Example old variables
Code:
defaults = {
    useDummy = false,
    startValue = 500
}

db = ZO_SavedVars:NewAccountWide("MyAddon_SavedVars", 1, nil, defaults)
Example new variables
Code:
defaults = {
    useDummy = false,
    startValue = 500,
    beAwesome = true
}

db = ZO_SavedVars:NewAccountWide("MyAddon_SavedVars", 1, nil, defaults)
And then I use the db variable with LibAddonMenu-2.0

When I give the new version to a user with old SavedVars they get an error. When I reinstall it, it works.
So for existing users the db variable does not include the new beAwesome value.

I have read about SavedVariables versioning here here https://www.esoui.com/forums/showthr...avedVars%3ANew
But then you would overwrite all existing SavedVars which is not what I want.

Is there a way to add a new variable and keep the old user settings?
  Reply With Quote