View Single Post
04-02-15, 10:47 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Lua Code:
  1. if event == "SPELL_AURA_APPLIED" or "SPELL_AURA_REFRESH" and sourceName == UnitName("player") and spellId == 126707 then
This means if the event is SPELL_AURA_APPLIED it's going to ignore the other conditions because you have "or" after it and it's short-circuiting.

Lua Code:
  1. if event == "SPELL_AURA_APPLIED" or "SPELL_AURA_REFRESH"
Also, this doesn't mean "if event == 'SPELL_AURA_APPLIED' or event == 'SPELL_AURA_REFRESH'", it's going to evaluate the string "SPELL_AURA_REFRESH" as an expression which is always going to be "true".

You can write it like this, although you should use the GUID of the player instead of their name which isn't necessarily unique, and you don't really need to query their name/GUID every time this is run, it would be better to store it in a variable when they log in.
Lua Code:
  1. if spellId == 126707 and sourceName == UnitName("player") and (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH") then

There's also no point in using select here, you may as well write your event handler like this..
Lua Code:
  1. eventFrame:SetScript("OnEvent", function(self, eventName, ...)
  2. local _, event, _, _, sourceName, _, _, _, _, _, _, spellId = ...

Last edited by semlar : 04-02-15 at 10:50 AM.
  Reply With Quote