View Single Post
06/23/14, 03:18 AM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
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:
  1. function Imperialization:Initialize()
  2.     Imperialization.savedVariables = ZO_SavedVars:New("ImperializationVariables", Imperialization.version, nil, Imperialization.Default)
  3.     LAM2:RegisterAddonPanel("ImperializationSettings", panelData)
  4.     LAM2:RegisterOptionControls("ImperializationSettings", optionsData)
  5.     EVENT_MANAGER:RegisterForEvent(Imperialization.name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, Imperialization.OnInventorySlotUpdate)
  6.     EVENT_MANAGER:UnregisterForEvent(Imperialization.name, EVENT_ADD_ON_LOADED)
  7. end
  8.  
  9. 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:
  1. local itemStyle = select(7, GetItemInfo(bagID, slotID))
  2. if Imperialization.savedVariables[itemStyle] == true then
  3.     if(Imperialization.savedVariables.DisplayResults) then
  4.         d(zo_strformat("<<t:1>> converted from the <<2>> style!", GetItemLink(bagID, slotID, LINK_STYLE_BRACKETS), GetString("SI_ITEMSTYLE", itemStyle)))
  5.     end
  6. end

Last edited by Garkin : 06/23/14 at 03:29 AM.
  Reply With Quote