Hi all,
Before BfA, I was able to check whether the specific buff/debuff exists or not by following lines of code.
Lua Code:
function eventFunction:UNIT_AURA(spellID)
local spellName = GetSpellInfo(spellID);
local _, _, count, _, duration, expiration = UnitBuff("player", spellName);
if (duration) then
-- Buff exists, do something
else
-- Buff does not exist, do something
end
end
But, since the querying with spell name is gone from BfA, what would be the best way to achieve the same behavior?
I currently have the following tho...
Lua Code:
function eventFunction:UNIT_AURA(id)
for i = 1, BUFF_MAX_DISPLAY do
local _, _, count, _, duration, expiratio, _, _, _, spellID = UnitBuff("player", i);
if (id == spellID) then
if (duration) then
-- Buff exists, do something
return; -- Buff found, no need to iterate any further
end
end
end
-- Buff does not exist, do something
end
Do I really have to loop through all the buffs to check?