View Single Post
08-25-14, 12:01 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That code is incomplete, as you didn't actually tell the frame what to do in response to events. Also:

- There's no need to use separate functions for the two events, as you want to do the same thing in response to both.

- You should use RegisterUnitEvent instead of RegisterEvent with UNIT_STATS so you don't have to manually filter out all other units.

- If your frame isn't a UI object shown the user, there's no need to give it a parent.

- A frame is already a table, so there's no need to create a separate table to hold functions.

Code:
-- updateFunction here

local frame = CreateFrame("Frame")
-- ^ If you already have a frame, you can register events on that instead of creating a new one here.
frame:RegisterEvent("COMBAT_RATING_UPDATE")
frame:RegisterUnitEvent("UNIT_STATS", "player")
frame:SetScript("OnEvent", updateFunction)
(On a side note, I really hope those "AgilityLine" etc. values are not globals. )
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote