WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Iterating through all players in raid for buff (https://www.wowinterface.com/forums/showthread.php?t=58534)

labmixz 01-08-21 04:39 PM

Iterating through all players in raid for buff
 
I'm sure this has been answered 1000x over, but trying to search on [these] forums, with the keywords I've been using hasn't brought me any results.

I'm looking to iterate over all the players in a raid, scanning for a buff. Without getting it to be too complex. Just wondering what the best method for doing this is? Lets say I want to look for Shadowcore Oil [spell id: 320798].


One tutorial I've found, has something like below. However, I can't see how this would iterate through all players in the raid. This seems more like it's iterating through the buffs on the player, which I need to do as well, just need to expand it to also include every other play (in raid).
Code:

local buffFound = 0
for i=1,40 do
    local name, icon, _, _, _, etime = UnitBuff("player",i)
    if name == "Shadowcore Oil" then
        buffFound = buffFound + 1
    end
end

Thanks in advance!

Edit: Of course I put this in the wrong forum :'( If someone could move it, that would be great.

Rilgamon 01-08-21 05:19 PM

Take a look at https://wow.gamepedia.com/API_AuraUtil.FindAuraByName

Lua Code:
  1. local name = AuraUtil.FindAuraByName("Shadowcore Oil", 'player')
  2. if(name) then
  3. print("Buff found.")
  4. end

and

Lua Code:
  1. for i = 1, MAX_RAID_MEMBERS do
  2. local unit = format("%s%i", 'raid', i)
  3. end

Lua Code:
  1. local buffFound = 0
  2. for i = 1, MAX_RAID_MEMBERS do
  3.     local unit = format("%s%i", 'raid', i)
  4.     local name = AuraUtil.FindAuraByName("Shadowcore Oil", unit)
  5.     if(name) then
  6.         buffFound = buffFound + 1
  7.     end
  8. end

labmixz 01-08-21 09:49 PM

Quote:

Originally Posted by Rilgamon (Post 338223)

Thanks very much!


All times are GMT -6. The time now is 04:00 AM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI