Thread Tools Display Modes
10-25-12, 05:31 AM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Tag for aura tracking with timer

I'm trying to create a tag that tracks a buff with a timer. With an Output something like "I: 29s". (Inquisition: 29seconds left)

I'm using code like this to track a buff. But how do I add a timer to it?

Code:
oUF.Tags.Methods["ProtoPWS"] = function(u) 
	if UnitAura(u, GetSpellInfo(17) or "Power Word: Shield") then return "|cffFFD800S|r" end end
oUF.Tags.Events["ProtoPWS"] = "UNIT_AURA"
I do not want to filter auras or something, should really be a tag.

I'm a little out of this stuff so bare with me, please.


I suppose it is something like this:
Code:
oUF.Tags.Methods['ITime'] = function(u) 
	local name, _,_,_,_,_, expirationTime, _ = UnitAura(u, GetSpellInfo(84963) or "Inquisition") 
    local spellTimer = GetTime()-expirationTime
	local expire = -1*(GetTime()-expirationTime)
	local timeleft = format("%.0f", expire)
	if expire > 0.5 then
		local spellTimer = "|cffffff00"..timeleft.."|r"
		return spellTimer
	end
end
oUF.Tags.Events['ITime'] = "UNIT_AURA"

but I always get an error on expirationTime:
Code:
Message: Interface\AddOns\oUF_Proto\Proto_Tags.lua:221: attempt to perform arithmetic on local 'expirationTime' (a nil value)
Time: 10/25/12 15:00:09
Count: 1
Stack: Interface\AddOns\oUF_Proto\Proto_Tags.lua:221: in function `?'
Interface\AddOns\oUF\elements\tags.lua:609: in function `UpdateTag'
Interface\AddOns\oUF\elements\tags.lua:441: in function `func'
Interface\AddOns\oUF\ouf.lua:158: in function `func'
Interface\AddOns\oUF\events.lua:113: in function `?'
Interface\AddOns\oUF\events.lua:76: in function <Interface\AddOns\oUF\events.lua:62>

Locals: u = "player"
name = nil
_ = nil
_ = nil
_ = nil
_ = nil
_ = nil
expirationTime = nil
_ = nil
(*temporary) = 1221857.275
(*temporary) = 1221857.275
(*temporary) = 0
(*temporary) = 0
(*temporary) = 0
(*temporary) = nil
(*temporary) = "attempt to perform arithmetic on local 'expirationTime' (a nil value)"
__________________
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 : 10-25-12 at 07:04 AM. Reason: experimental code added
  Reply With Quote
10-25-12, 07:23 AM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
This seems to work error free, but it updates only every few seconds ... like 30 ... 23 ... 11 ... 7 ...

Code:
oUF.Tags.Methods['ITime'] = function(u) 
local name, _,_,_,_,_, expirationTime, _ = UnitAura(u, GetSpellInfo(84963) or "Inquisition") 
	if UnitAura(u, GetSpellInfo(84963) or "Inquisition") then		
		local spellTimer = GetTime()-expirationTime
		local expire = -1*(GetTime()-expirationTime)
		local timeleft = format("%.0f", expire)
		if expire > 0.5 then
			local spellTimer = "|cffffff00"..timeleft.."|r"
			return spellTimer
		end
	end	
end
oUF.Tags.Events['ITime'] = "UNIT_AURA"

No matter what I tried, it somehow won't update every second ... :P

Note: The "unit" I'm using this tag on is 'player', but contains no healthbar. Which means the font string is created on self, not self.Health. I suppose frequent updates don't work this way, which might be the reason for the slow update of my timer?
__________________
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 : 10-25-12 at 07:42 AM.
  Reply With Quote
10-25-12, 09:13 AM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
The tags run on their own update system. With your current code it will only update when UNIT_AURA fires. You need to set 'frequentUpdates' to true (or a threshold number) to make the tag pull updates.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
10-25-12, 11:04 AM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Ok, that's what I was thinking, but I kinda forgot how to use 'frequentUpdates' and couldn't find how to use it, except for the obvious 'hp.frequentUpdates = true'.

tried stuff like ...
self.frequentUpdates = true (self = said player frame)
self.cpCount.frequentUpdates = true ( self.cpCount = the fontstring holding the tag)

same with values = 0.2, 0.1 ...

No effect. Maybe it's not the problem how to use it, but the code being crap.

Again sorry for being obviously confused, but it's been over a year of absence.


E: Since I'm already on it ... 'oUF.UnitlessTagEvents.UPDATE_FACTION = true' doesn't seem to work anymore, does 'oUF.Tags.SharedEvents.UPDATE_FACTION = true' work instead? Or how is this unitless tag update stuff handled, atm?
__________________
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 : 10-25-12 at 11:13 AM.
  Reply With Quote
10-25-12, 12:36 PM   #5
nin
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 213
Here's an example of a tag i use for timers that i got from quse...

Eternal Flame timer.

Lua Code:
  1. oUF.Tags.Methods['EF'] = function(u)
  2.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(114163))
  3.     if(fromwho == "player") then
  4.         local spellTimer = (expirationTime-GetTime())
  5.         local TimeLeft =  numberize(spellTimer)
  6.         if spellTimer > 0 then
  7.             return "|cffFFAB00"..TimeLeft.."|r"
  8.         end
  9.     end
  10. end
  11. oUF.Tags.Events['EF'] = "UNIT_AURA"

I use indicator strings.

Lua Code:
  1. local update = .25

Lua Code:
  1. auraStatusBR = self.Health:CreateFontString(nil, "OVERLAY")
  2.             auraStatusBR:ClearAllPoints()
  3.             auraStatusBR:SetPoint("BOTTOMRIGHT", 0, 7)
  4.             auraStatusBR:SetFont(Media.font, 14, "OUTLINE")
  5.             auraStatusBR.frequentUpdates = update
  6.             self:Tag(auraStatusBR, oUF.Indicators["BR"])

Hope that's of any help
  Reply With Quote
10-25-12, 01:12 PM   #6
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
This helped me figuring out where to place that damn frequentupdate, thanks a lot.

Couldn't test it on my pala, yet. Servers still f***ed up, but worked with rejuvenation on a twink.
__________________
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..."

  Reply With Quote
10-25-12, 03:30 PM   #7
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Works like a charm


Holy Power and Inquisition timer (timer turns red at <= 6sec).
__________________
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..."

  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Tag for aura tracking with timer


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