The easiest way to fix this issue is to register event after you have saved variables available - i.e. move event registration to the Initialize function:
Lua Code:
function Imperialization:Initialize()
Imperialization.savedVariables = ZO_SavedVars:New("ImperializationVariables", Imperialization.version, nil, Imperialization.Default)
LAM2:RegisterAddonPanel("ImperializationSettings", panelData)
LAM2:RegisterOptionControls("ImperializationSettings", optionsData)
EVENT_MANAGER:RegisterForEvent(Imperialization.name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, Imperialization.OnInventorySlotUpdate)
EVENT_MANAGER:UnregisterForEvent(Imperialization.name, EVENT_ADD_ON_LOADED)
end
EVENT_MANAGER:RegisterForEvent(Imperialization.name, EVENT_ADD_ON_LOADED, Imperialization.OnAddOnLoaded)
By the way I think it's not a good idea to use addon version as a version of your saved variables. It will reset everything to the defaults with each new addon version.
EDIT:
Another suggestion - Conditions you use looks rather complicated. If you use itemSyle as a key in your saved variables, you can use much easier condition:
lua Code:
local itemStyle = select(7, GetItemInfo(bagID, slotID))
if Imperialization.savedVariables[itemStyle] == true then
if(Imperialization.savedVariables.DisplayResults) then
d(zo_strformat("<<t:1>> converted from the <<2>> style!", GetItemLink(bagID, slotID, LINK_STYLE_BRACKETS), GetString("SI_ITEMSTYLE", itemStyle)))
end
end