Thread Tools Display Modes
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
09-19-18, 08:46 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
No. There is AuraUtil.FindAuraByName
https://www.townlong-yak.com/framexm...uraUtil.lua#32

Example: https://github.com/zorker/rothui/blo...a/core.lua#L60
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-19-18, 08:59 AM   #3
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
Originally Posted by zork View Post
WoW....

Why did the Blizzard make such decisions...?

Last edited by Lyak : 09-19-18 at 09:04 AM.
  Reply With Quote
09-19-18, 10:15 PM   #4
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
They don't make us privy to their internal logic but there are numerous reasons to make the type of architectural changes they've made in the API. It's not uncommon for this type of thing to happen as projects age, grow in complexity, and need to be balanced for better maintenance, to better integrate with new development priorities, or to provide a more solid base for future development.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote

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

Thread Tools
Display Modes

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