Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-19-18, 08:19 AM   #1
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
UnitAura/UnitBuff/UnitDebuff changes in BfA

Hi all,

Before BfA, I was able to check whether the specific buff/debuff exists or not by following lines of code.

Lua Code:
  1. function eventFunction:UNIT_AURA(spellID)
  2.     local spellName = GetSpellInfo(spellID);
  3.  
  4.     local _, _, count, _, duration, expiration = UnitBuff("player", spellName);
  5.  
  6.     if (duration) then
  7.         -- Buff exists, do something
  8.     else
  9.         -- Buff does not exist, do something
  10.     end
  11. 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:
  1. function eventFunction:UNIT_AURA(id)
  2.     for i = 1, BUFF_MAX_DISPLAY do
  3.         local _, _, count, _, duration, expiratio, _, _, _, spellID = UnitBuff("player", i);
  4.  
  5.         if (id == spellID) then
  6.             if (duration) then
  7.                 -- Buff exists, do something
  8.  
  9.                 return; -- Buff found, no need to iterate any further
  10.             end
  11.         end
  12.     end
  13.  
  14.     -- Buff does not exist, do something
  15. end

Do I really have to loop through all the buffs to check?

Last edited by Lyak : 09-19-18 at 08:32 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » UnitAura/UnitBuff/UnitDebuff changes in BfA


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off