WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   hiding frames from UnitAura (https://www.wowinterface.com/forums/showthread.php?t=50621)

ObbleYeah 11-30-14 11:05 AM

hiding frames from UnitAura
 
Hullo, i'm building a simple function that will display a filtered list of important auras on my raid frames:

http://abload.de/img/screenshot2014-11-30ay0d0z.png

This is the code i currently have:

https://gist.github.com/anonymous/dda27accffef2b17ce43

Now, the auras I want to track will successfully show when they appear on the unit. But they won't bugger off again when it's dispelled or the duration runs out, as you can see in the picture above. I assume i'm just getting the logic wrong on in terms of when to show/hide, but the right method is eluding me today :( can anyone help?

Phanx 11-30-14 12:36 PM

Without seeing your entire, actual code -- Seriously, why do people never post it?! If you don't know what the problem is, why do you think you do know where it is? :rolleyes: -- offhand I'd say a potential problem is that you're not stopping the loop after you handle a buff, so even if you find one buff you want to show, you keep going, and possibly find another buff you don't want to show, causing the frame to be hidden. If you only want to show one buff at a time, add a "break" statement in there; if you want to show multiple buffs at a time, you need more than one frame, or at least more than one texture, but based on the snippet you posted it looks like you only have one.

ObbleYeah 11-30-14 01:00 PM

here's the whole thing, was previously whittled down because there's a lot of shit going on I guess. Relevant stuff starts around line 220

https://gist.github.com/anonymous/50c4497b6f3b960d63b4

it's intended to just have the one aura texture shown, and i was planning on having a priority set up in the table for each spell on the whitelist.

The problem is that I never reach the point where my test print will fire and the frame will be hidden, assumedly because my if else chain is dumb. Not sure if a break will fix that issue, though it might be needed anyway!

ObbleYeah 11-30-14 01:29 PM

got it

Lua Code:
  1. local function raid_Auras(self, unit)
  2.         for i = 1, 40 do
  3.             local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i)
  4.             if (dispel and dispel[dtype]) or (cfg.raidAuras and cfg.raidAuras[name]) then
  5.                 self.Graphics.Auras:Show()
  6.                 self.Graphics.AurasTexture:SetTexture(icon)
  7.                 if beauty and self.Graphics.Auras:IsShown() then
  8.                     local colour = DebuffTypeColor[dtype] or DebuffTypeColor.none
  9.                     self.Graphics.Auras:SetBeautyBorderColor(colour.r, colour.g, colour.b)
  10.                 end
  11.                 break
  12.             else
  13.                 self.Graphics.Auras:Hide()
  14.                 self.Graphics.AurasTexture:SetTexture''
  15.             end
  16.         end
  17.     end

thanks!

ObbleYeah 12-01-14 02:39 PM

okay new issue when trying to implement a priority to my whitelist table, here's the relevant code:

https://gist.github.com/anonymous/5153d080d60659e6725f

Basically, once one aura is successfully raised and shown - no others will pass.

Lets say I cast Ice Barrier then Ice Ward; the latter should overwrite the former and textures should update to reflect that. Instead the texture remains the same and i'll get two prints of 'Ice Barrier'.

My guess is that the break is at fault - it's not letting anymore auras pass after the first is found. If I remove that I'm back to square one though. :confused:

Phanx 12-15-14 01:40 PM

Don't know if you solved this, but if not, the problem was that you were trying to update things in the middle of the scan (and also, for some reason, keeping track of the priority from the last scan even though it may not even be relevant for the next one). Here's a better method that will scan all of the buffs on the unit and only update the display once after the scan is complete.

Code:

local function raid_Auras(self, unit)
        local bestPriority, bestIcon, bestType = 0
        for i = 1, 40 do
                local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i)
                if not name then break end -- no more auras on this unit
                local priority = (list.dispel and list.dispel[dtype]) and 5 or (list.raidAuras and list.raidAuras[name])
                  if priority and priority > bestPriority then
                        bestPriority = priority
                        bestIcon, bestType = icon, dtype
                end
        end
        if bestIcon then
                self.Graphics.Auras:Show()
                self.Graphics.AurasTexture:SetTexture(bestIcon)
                if beauty then
                        local colour = DebuffTypeColor[dtype] or DebuffTypeColor.none
                        self.Graphics.Auras:SetBeautyBorderColor(colour.r, colour.g, colour.b)
                end
        else
                self.Graphics.Auras:Hide()
        end
end

On a side note, since this function is only looking at buffs, there's no need to check whether each aura is of a type the player can dispel, since dispelling only applies to debuffs. However, I left that in, in case you want to apply the same code to debuffs in the future; I gave dispellable debuffs a priority of 5, since another issue was that they didn't have a priority and thus would probably cause errors when encountered.

ObbleYeah 12-23-14 03:54 AM

Dunno how I didn't see this 'til now. Thanks hugely - will test tonight.

edit: you say this is currently only running through buffs? I thought UnitAura passed both buffs & debuffs? Do I need to add a filter?

ObbleYeah 12-28-14 04:06 AM

just bumping this up, interested to know why the function only processes buffs currently.

Phanx 12-28-14 09:40 AM

The function only processes buffs because it only includes code to process buffs. If you do not pass a filter, UnitAura defaults to looking at buffs. If you want to look at both buffs and debuffs you need to do two loops -- one for buffs, one for debuffs.
Code:

        -- Buffs:
        for i = 1, 40 do
                local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i)
                if not name then break end -- no more buffs on this unit
                local priority = list.raidAuras and list.raidAuras[name]
                  if priority and priority > bestPriority then
                        bestPriority = priority
                        bestIcon, bestType = icon, dtype
                end
        end
        -- Debuffs:
        for i = 1, 40 do
                local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i, "HARMFUL")
                if not name then break end -- no more debuffs on this unit
                local priority = (list.dispel and list.dispel[dtype]) and 5 or (list.raidAuras and list.raidAuras[name])
                  if priority and priority > bestPriority then
                        bestPriority = priority
                        bestIcon, bestType = icon, dtype
                end
        end

(Also, I never saw your question, because you just edited your post, and that doesn't flag the thread as unread. Generally if it's been more than 5-10 minutes and your original post didn't including anything that requires a reply, you should just add another post.)

ObbleYeah 12-30-14 05:51 PM

Ah, interesting - and it looks like there's no way to filter both ways in one call of UnitAura? Good to know.

Phanx 12-30-14 06:10 PM

No, and I'm not even sure how that would work... each UnitAura call is a discrete, stateless action. If you say "tell me about the 5th aura on the player unit" how can that refer to both the 5th buff and the 5th debuff? The API isn't aware that you're calling UnitAura from inside a loop, or a function, or even a file. All it knows is that (a) the function is being called and (b) the string "unit" and the number 5 are being provided with the function call. Since it can only return information about one aura, "the 5th aura" can only mean "the 5th buff" or "the 5th debuff" -- not both at the same time.


All times are GMT -6. The time now is 12:55 PM.

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