WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   UnitAura/UnitBuff/UnitDebuff changes in BfA (https://www.wowinterface.com/forums/showthread.php?t=56687)

Lyak 09-19-18 08:19 AM

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?

zork 09-19-18 08:46 AM

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

Lyak 09-19-18 08:59 AM

Quote:

Originally Posted by zork (Post 330162)

WoW....

Why did the Blizzard make such decisions...?

VincentSDSH 09-19-18 10:15 PM

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.


All times are GMT -6. The time now is 10:46 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI