Quantcast

Make sure AddonLoader works nicely

Adrian L Lange [06-27-10 - 05:07]
Make sure AddonLoader works nicely
Filename
Broker_Equipment.lua
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)