View Single Post
12-04-09, 05:04 AM   #37
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by haste View Post
That should work fine, unless you remove timeLeft at a later point :P
Wall of Text inc....

I reduced the code to this (I left in what I uncommented for reference):

Code:
-- duration text
local function auraUpdateTimeShort(self, elapsed)
	self.timeLeft = math.max(self.timeLeft - elapsed, 0)
	self.time:SetText(self.timeLeft < 120 and math.floor(self.timeLeft) or '')
end

local function auraUpdateIcon(self, icons, unit, icon, index, offset, filter, isDebuff, duration, timeLeft)
    if(unit == "target")or(unit == "focus") then
		local _, _, _, _, dtype = UnitAura(unit, index, icon.filter)

		if(icon.debuff) then
			icons.showDebuffType = false		
			if(icon.owner ~= 'player' and icon.owner ~= 'vehicle') then
			icon:SetBackdropColor(0, 0, 0)
			icon.overlay:SetVertexColor(trdcolor[1], trdcolor[2], trdcolor[3])			
			icon.icon:SetDesaturated(true)
			else
			local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
			icon:SetBackdropColor(color.r * 0.9, color.g * 0.9, color.b * 0.9)
			icon.overlay:SetVertexColor(color.r * 0.9, color.g * 0.9, color.b * 0.9)			
			icon.icon:SetDesaturated(false)
			end
		end	
	end

	if(unit) or (self:GetParent():GetName():match"oUF_Party") then 
			local _, _, _, _, _, duration, timeLeft = UnitAura(unit, index, filter)

		icon.timeLeft = timeLeft - GetTime()			
		icon:SetScript('OnUpdate', auraUpdateTimeShort)	
		
		--if duration == 0 and not timeLeft then
			--icon.timeLeft = nil
			--icon.time:SetText()
			--icon:SetScript('OnUpdate', nil)
		--end
	end
end

--[[ sorting nightmare
local customAuraFilter = function(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster)
	local isPlayer

	if(caster == 'player' or caster == 'vehicle') then
		isPlayer = true
	end
	
	if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then
		icon.isPlayer = isPlayer
		icon.owner = caster
		
		if( timeLeft == 0 ) then
			icon.timeLeft = math.huge
		else
			icon.timeLeft = timeLeft
		end
		return true
	end
end
--]]	  
local sort = function(a, b)
	return a.timeLeft > b.timeLeft
end
	  
local preAuraSetPosition = function(self, icon, max)
	table.sort(icon, function(a,b) return a.timeLeft > b.timeLeft end)
end

As you can see I could easily get rid of the customfilter, since timeleft is part of the duration function, already. This code show duration and it sorts fine on player, target and focus. When I join a group and someone in there has a buff, the following error block pops up...

Code:
Message: Interface\AddOns\oUF_viv\oUF_viv.lua:423: attempt to compare number with nil
Time: 12/04/09 11:58:23
Count: 1
Stack: [string "Interface\FrameXML\BasicControls.xml:<Scrip..."]:18: in function <[string "Interface\FrameXML\BasicControls.xml:<Scrip..."]:4>
[C]: ?
Interface\AddOns\oUF_viv\oUF_viv.lua:423: in function <Interface\AddOns\oUF_viv\oUF_viv.lua:423>
[C]: in function `sort'
Interface\AddOns\oUF_viv\oUF_viv.lua:423: in function `PreAuraSetPosition'
Interface\AddOns\oUF\elements\aura.lua:293: in function `func'
Interface\AddOns\oUF\ouf.lua:316: in function `PLAYER_ENTERING_WORLD'
Interface\AddOns\oUF\ouf.lua:166: in function <Interface\AddOns\oUF\ouf.lua:153>
[C]: in function `SetAttribute'
Interface\FrameXML\SecureTemplates.lua:816: in function <Interface\FrameXML\SecureTemplates.lua:729>
Interface\FrameXML\SecureTemplates.lua:1024: in function `SecureGroupHeader_Update'
Interface\FrameXML\SecureTemplates.lua:616: in function <Interface\FrameXML\SecureTemplates.lua:614>
[C]: in function `SetAttribute'
Interface\FrameXML\SecureTemplates.lua:776: in function <Interface\FrameXML\SecureTemplates.lua:729>
Interface\FrameXML\SecureTemplates.lua:1024: in function <Interface\FrameXML\SecureTemplates.lua:905>
[C]: in function `Show'
Interface\AddOns\oUF_viv\oUF_viv.lua:1404: in main chunk

Locals: a = <unnamed> {
 overlay = <unnamed> {
 }
 time = <unnamed> {
 }
 cd = <unnamed> {
 }
 count = <unnamed> {
 }
 parent = <unnamed> {
 }
 frame = oUF_PartyUnitButton1 {
 }
 icon = <unnamed> {
 }
 0 = <userdata>
}
b = <unnamed> {
 overlay = <unnamed> {
 }
 0 = <userdata>
 parent = <unnamed> {
 }
 owner = "player"
 timeLeft = 1161.107
 isPlayer = true
 count = <unnamed> {
 }
 filter = "HELPFUL"
 time = <unnamed> {
 }
 frame = oUF_PartyUnitButton1 {
 }
 icon = <unnamed> {
 }
 cd = <unnamed> {
 }
}
(*temporary) = nil
(*temporary) = 1161.107
(*temporary) = "attempt to compare number with nil"
While line 423 is this (the red one):

Code:
local preAuraSetPosition = function(self, icon, max)
	table.sort(icon, function(a,b) return a.timeLeft > b.timeLeft end)
end

What I did to temporarily fix it - I'm only settting
Code:
		self.PreAuraSetPosition = preAuraSetPosition
for player target and focus, instead of setting it for all frames at the end of the layout.

This results in no error, duration text on party members, but no sorting for party. It sorts + duration for player, target, focus, ofc. I have no idea why it doesn't work on party frames (maybe raid, too haven't tested that), without any issues for said frames.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 12-04-09 at 05:06 AM.
  Reply With Quote