View Single Post
09-28-16, 11:29 PM   #4
luanoob
A Murloc Raider
Join Date: Sep 2016
Posts: 4
Originally Posted by Sweetsour View Post
Well, UNIT_AURA fires when a unit's auras have changed. So when this fires, it sends you the unit that caused the event to fire. So you'd want to try something like this:

Lua Code:
  1. Code
Hello and thanks!

I tried your code but the only difference it made was that the text "ROLL THE BONES" showed all the time when not in combat, while before it would pop up whenever i used a buff like sprint when not in combat. So it didnt really fix my problem, since i would only like to have it show when in combat.

Originally Posted by Seerah View Post
UNIT_AURA fires for all valid units, not just the player. The unit it fires for will be the first argument past the event name itself, and you should check if it is the unit you wish to watch for.

A better method would be to register the event specifically for the player, using
Lua Code:
  1. textframe:RegisterUnitEvent("UNIT_AURA", "player")
Then your addon will only be notified when it fires for your player.
http://wow.gamepedia.com/API_Frame_RegisterUnitEvent

Also, you don't need to use HookScript for a frame that you've created. You know which scripts are set to it, which aren't, and what they do. HookScript is good when dealing with other addons' (or the default UI's) frames when you don't want to overwrite (or possibly overwrite) what scripts are already present.
Hey, I tried your suggested changes as well but when changing to
Lua Code:
  1. textframe:RegisterUnitEvent("UNIT_AURA", "player")
the text would not show at all.
  Reply With Quote