Thread: best practice
View Single Post
04-10-16, 08:44 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
The issue with your code, is that you register events even before your addon loads which can make a lot of unneccessary calls. In this case specially when you would log into combat.

You should do something like:
Lua Code:
  1. local ADDON = ...
  2.  
  3. local frame = CreateFrame("FRAME")
  4. frame:RegisterEvent("ADDON_LOADED")
  5.  
  6. frame:SetScript("OnEvent", function(self, event, ...)
  7.     if event == "ADDON_LOADED" and ... == ADDON then
  8.         self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  9.         self:RegisterEvent("PLAYER_ENTERING_WORLD")
  10.         self:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
  11.         self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  12.     elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
  13.        
  14.     end
  15. end)
  Reply With Quote