First what you would need to do is check if the given unit by
UNIT_AURA is 'player'. This event runs pretty often, and for each unit.
lua Code:
local unit = ... -- select the first argument from arguments passed
if unit ~= 'player' then return end -- run code only for player unit
Using return will skip out of the function stopping any processing of code. It's just a way of avoiding too many nested if then end's.
Then you know it's the player that gained or lost a buff. You want to see if the player has gained righteous fury. To see that, we use
UnitBuff:
lua Code:
local active = UnitBuff('player', 'Righteous Fury')
if active then
print('Righteous Fury has been activated')
end
or even
lua Code:
if UnitBuff('player', 'Righteous Fury') then
print('Righteous Fury has been activated')
end
But what will happen, is that will fire off every time you get or loose an aura, resulting in chat spam. So we solve that with a variable called 'hasrf':
lua Code:
local active = UnitBuff('player', 'Righteous Fury')
if not hasrf and active then -- we gained righteous fury as we did not have it before and it's active now
hasrf = true
print('Righteous Fury has been activated')
elseif hasrf and not active then -- we lost righteous fury as we did have it before and it's no longer active now
hasrf = false
end
Be sure to define 'hasrf' as a local variable outside your eventhandler function