Thread Tools Display Modes
11-30-14, 11:05 AM   #1
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
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?

Last edited by ObbleYeah : 11-30-14 at 11:09 AM.
  Reply With Quote
11-30-14, 12:36 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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? -- 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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-30-14, 01:00 PM   #3
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
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!
  Reply With Quote
11-30-14, 01:29 PM   #4
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
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!
  Reply With Quote
12-01-14, 02:39 PM   #5
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
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.
  Reply With Quote
12-15-14, 01:40 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-23-14, 03:54 AM   #7
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
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?

Last edited by ObbleYeah : 12-23-14 at 05:12 AM.
  Reply With Quote
12-28-14, 04:06 AM   #8
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
just bumping this up, interested to know why the function only processes buffs currently.
  Reply With Quote
12-28-14, 09:40 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 12-28-14 at 09:42 AM.
  Reply With Quote
12-30-14, 05:51 PM   #10
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
Ah, interesting - and it looks like there's no way to filter both ways in one call of UnitAura? Good to know.
  Reply With Quote
12-30-14, 06:10 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » hiding frames from UnitAura

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