Thread Tools Display Modes
02-01-15, 11:35 AM   #1
matt.wow
A Murloc Raider
Join Date: Jan 2011
Posts: 5
Aura sort - table correct, buffs not

Hi,

just got started with LUA and currently working on my own oUF layout.

I run into a problem with aura sorting and can't figure out what I'm doing wrong.

What I plan to to:

- display auras on my playerframe selected by the spellID using the filter function (working)
- sorting the auras by a manual assigned priority
- sorting goes like: auras I want to show in a special order > auras I don't want to show > unused icons

The funny stuff is that the table sorts exactly the way I want it to. But the displayed Auras show really strange behaviors. Buffs are missing. empty icons showing up. Nothing gets sorted at all.

Please enlighten me how hard I fail at LUA!

The code:

Aura list:
Code:
local spells = {
	[12880] = 1, -- Enrage (Warrior)
	[169667] = 2, -- Shield Charge (Warrior)
	
	[47788] = 20, -- Guardian Spirit (Priest)
	[33206] = 21, -- Pain Suppression (Priest)
	[62618] = 22, -- Power Word: Barrier (Priest)
	
	[114039] = 12, -- Hand of Purity (Paladin)
	[6940] = 11, -- Hand of Sacrifice (Paladin)
	[1022] = 10, -- Hand of Protection (Paladin)
	
	[172106] = 5, -- Aspect of the Fox (Hunter)
	
	[5171] = 1, -- Slice and Dice (Rogue)
	[84745] = 2, -- Shallow Insight (Rogue)
	[84746] = 3, -- Moderate Insight (Rogue)
	[84747] = 4, -- Deep Insight (Rogue)
}
Filter:
Code:
function FilterPlayerAuras(self, unit, icon, ...)
	local _, _, _, _, _, _, _, _, _, _, id = ...

	icon.spellID = id -- just in case I need it

	if(spells[id]) then
		icon.spellPrio = spells[id]
		return true
	else
		icon.spellPrio = math.huge
		return true -- set to true for testing sort
	end
end
Sorting:
Code:
local SortAuras = function(a, b)
	if (a:IsShown() and b:IsShown()) then
		return a.spellPrio < b.spellPrio
	elseif (a:IsShown()) then
		return true
	end
end
Code:
local PreSetPosition = function(Auras)
	table.sort(Auras, SortAuras)
end
Function to show the table contend for testing. Not mine, found it here and modified it.
Code:
local PrintAuras = function(Auras)
	local button
	local text = {}

	for i = 1, #Auras do
		button = Auras[i]
		if (not button) then
			tinsert(text, i, "NC") -- not created
		elseif (button:IsShown()) then
			local _, _, icon = GetSpellInfo(button.spellID)
			if (button.spellPrio == math.huge) then
				tinsert(text, i, "|cffff0000(|r".."|T"..icon..":0|t".."|cffff0000)|r")
			else
				tinsert(text, i, "|cff00ff00(|r".."|T"..icon..":0|t".."|cff00ff00)|r")
			end
		else
			tinsert(text, i, "U") -- unused, hidden
		end
	end
	return table.concat(text, "-")
end
  Reply With Quote
02-02-15, 12:15 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I don't see anything obviously wrong in the snippets you posted, but generally, posting isolated snippets is not particularly useful. Where's the rest of your aura element code? Where are you actually using the functions you posted? Why is "FilterPlayerAuras" a global?

Edit: Actually, I might see something wrong... your PreSetPosition function should return 0 to force oUF to actually reposition the icons. Otherwise you'll probably end up with some icons on top of each other, which will look like holes and missing icons.
__________________
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 : 02-02-15 at 12:18 AM.
  Reply With Quote
02-02-15, 06:08 AM   #3
matt.wow
A Murloc Raider
Join Date: Jan 2011
Posts: 5
Originally Posted by Phanx View Post
Why is "FilterPlayerAuras" a global?
Oops

Originally Posted by Phanx View Post
your PreSetPosition function should return 0 to force oUF to actually reposition the icons.
return 0 results in an error in the oUF aure element.

return 1 works and fixed my problem. Thanks!
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Aura sort - table correct, buffs not


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