From 8926fa1f8108d3eff3884c8c9dc9c2971b052488 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Sun, 27 Jun 2010 07:07:34 +0200 Subject: [PATCH] Make sure AddonLoader works nicely --- Broker_Equipment.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Broker_Equipment.lua b/Broker_Equipment.lua index 37d9e61..d8daf41 100644 --- a/Broker_Equipment.lua +++ b/Broker_Equipment.lua @@ -119,7 +119,7 @@ function addon:initialize(...) end end -function addon:PLAYER_LOGIN(event) +function addon:PLAYER_LOGIN() self.info = {} self.displayMode = 'MENU' self:RegisterEvent('UNIT_INVENTORY_CHANGED') @@ -127,6 +127,13 @@ function addon:PLAYER_LOGIN(event) self:UNIT_INVENTORY_CHANGED() end +function addon:ADDON_LOADED(name, event) + if(name == addonName) then + self:UnregisterEvent(event) + self:PLAYER_LOGIN() + end +end + function addon:UNIT_INVENTORY_CHANGED(unit, event) if(unit and unit ~= 'player') then return end @@ -160,5 +167,5 @@ function addon:VARIABLES_LOADED(var, event) self:UnregisterEvent(event) end -addon:RegisterEvent('PLAYER_LOGIN') +addon:RegisterEvent(IsAddOnLoaded('AddonLoader') and 'ADDON_LOADED' or 'PLAYER_LOGIN') addon:SetScript('OnEvent', function(self, event, ...) self[event](self, ..., event) end) -- 1.7.9.5