I have a problem with simple code ((
My menu allways show only default value!
setFunc works right and changes variable
ZO_SavedVars works right and load/saves variable
When I change variable by menu, key bind, slash command, or any other way and returns to menu… it allways show default value! Where is my mistake?
Code:
Addon = {
name = "Addon",
Menu = {},
Vars = {},
Defaults = {
["OnOff"] = true,
}
};
function Addon.Menu()
local options = {
{ type = "header",
name = "Options",
width = "full"
},
{ type = "checkbox",
name = "Enables add-on",
tooltip = "",
getFunc = function() return Addon.Vars.OnOff end,
setFunc = function(value) Addon.Vars.OnOff =value end,
default = Addon.Defaults.OnOff,
},
local menu = LibStub("LibAddonMenu-2.0")
local panel = {
type = "panel",
name = "Add-on",
displayName = "Add-on",
author = "autor",
version = "1",
}
menu:RegisterAddonPanel("AddonMenu", panel)
menu:RegisterOptionControls("AddonMenu", options)
end
function Addon.OnAddOnLoaded( eventCode, addonName )
if (addonName ~= Addon.name) then return end
EVENT_MANAGER:UnregisterForEvent(Addon.name, EVENT_ADD_ON_LOADED)
Addon.Vars = ZO_SavedVars:NewAccountWide( "Addon_Settings" , version , nil , Addon.Defaults )
Addon.Menu()
end