I have figured out what is bugged, I was not expecting this..
There is a problem with the new event EVENT_NON_COMBAT_BONUS_CHANGED, it fires on logout to character selection screen and I guess at quit game also.
I hope I am correct in assuming this event should only fire when playing on your character when the skills are changed and not when going to the character selection screen or quitting the game.
Brand new example addon and code:
Name: TestAddon
SavedVariables file: TestAddon
Test value: TestAddon.settings.test.something
Steps:
1. Pick a character and log in
2. /reloadui
3. Check SV file
4. TestAddon.settings.test.something = "First"
5. Log out to character selection screen
6. Check SV file
7. TestAddon.settings.test.something = "Non Combat"
TestAddon.lua:
Lua Code:
local function OnNonCombatBonusChanged(eventCode, nonCombatBonusType)
TestAddon.settings.test.something = "Non Combat"
end
local function DefaultSettings()
local defaults = {
test = {}
}
return defaults
end
local function OnPlayerActivated()
if TestAddon.player_activated then return end
TestAddon.player_activated = true
EVENT_MANAGER:UnregisterForEvent("TestAddon", EVENT_PLAYER_ACTIVATED)
TestAddon.settings.test.something = "First"
end
local function OnLoaded(eventType, addonName)
if addonName ~= "TestAddon" then return end
TestAddon.settings = ZO_SavedVars:NewAccountWide("TestAddonSettings", 1, nil, DefaultSettings())
EVENT_MANAGER:RegisterForEvent("TestAddon", EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
EVENT_MANAGER:RegisterForEvent("TestAddon", EVENT_NON_COMBAT_BONUS_CHANGED, OnNonCombatBonusChanged)
end
TestAddon = {
player_activated = false
}
EVENT_MANAGER:RegisterForEvent("TestAddon", EVENT_ADD_ON_LOADED, OnLoaded)
TestAddon.txt
Code:
## Title: TestAddon
## APIVersion: 100020
## SavedVariables: TestAddonSettings
## Version: 1.0
TestAddon.lua
SavedVariables File TestAddon.lua After reloadui
Lua Code:
TestAddonSettings =
{
["Default"] =
{
["@Weolo"] =
{
["$AccountWide"] =
{
["version"] = 1,
["test"] =
{
["something"] = "First",
},
},
},
},
}
SavedVariables File TestAddon.lua After log out to character selection screen
Lua Code:
TestAddonSettings =
{
["Default"] =
{
["@Weolo"] =
{
["$AccountWide"] =
{
["version"] = 1,
["test"] =
{
["something"] = "Non Combat",
},
},
},
},
}