Thread Tools Display Modes
04-09-13, 01:23 PM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
how to track a weapon enchant proc with a tag

As the title suggest I'm trying to track weapon enchant procs (like Dancing Steel, Colossus, ...) with a tag.

I'm using this code to track all kinds of other "normal" buffs.

for instance, this one tracks the PvP strength trinket proc. The same code also works for things like Sacred Shield, Renew, ...
Code:
oUF.Tags.Methods['GhostSoVTime'] = function(u) -- PvP Trinket Strength Proc
local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(126700) or "Surge of Victory")
    if(fromwho == "player") then
        local spellTimer = (expirationTime-GetTime())
		local TimeLeft = format("%.0f", spellTimer)
			return "|cfffaaaab"..TimeLeft.."|r"
    end
end
oUF.Tags.Events['GhostSoVTime'] = "UNIT_AURA"
When I'm using said code to track, let's say, Dancing Steel. It shows nothing.

I suppose it's because "fromwho" fails to return anything for weapon enchant procs? Since the "casterID" (aka fromwho) can only be player, but even if I use "if fromwho == "none"" or just "if fromwho then". It still returns nothing.

So how do I have to adapt the code to track weapon enchant procs?



Edit: Found a way ... just checking for the name instead of owner.

Code:
oUF.Tags.Methods['GhostDSTime'] = function(u) -- Dancing Steel Enchant Proc id 120032 or 118335
local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(120032) or "Dancing Steel")
    if (name == "Dancing Steel") then
        local spellTimer = (expirationTime-GetTime())
		local TimeLeft = format("%.0f", spellTimer)
			return "|cff6670FF"..TimeLeft.."|r"
    end
end
oUF.Tags.Events['GhostDSTime'] = "UNIT_AURA"
__________________
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 : 04-09-13 at 01:30 PM.
  Reply With Quote
04-09-13, 03:04 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You should avoid doing a GetSpellInfo lookup on every UNIT_AURA event. You can also avoid the cost of the string concatenation by including the color codes directly in your format pattern.

Code:
local DANCING_STEEL = GetSpellInfo(120032)
oUF.Tags.Events["GhostSDTime"] = "UNIT_AURA"
oUF.Tags.Methods["GhostDSTime"] = function(u)
    local _, _, _, _, _, _, expirationTime = UnitAura(u, DANCING_STEEL)
    if expirationTime then
        return format("|cff6670ff%.0f|r", expirationTime - GetTime())
    end
end
__________________
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
04-11-13, 07:33 AM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Problem was, if I didn't check for casterID (fromwho), I kept getting an error on "expirationTime".

I'll try the code, will stick with your formatting, it's cleaner. Thanks.


E: Works nicely, thanks again Phanx.
__________________
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 : 04-11-13 at 07:46 AM.
  Reply With Quote
04-11-13, 08:52 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It's usually best to just check the most directly related thing -- in this case, the data you actually want to work with is the expiration time, so just check if that has a value. If it does, you're good to go. Checking other things like the buff name or caster unit may work, but is really just superfluous and doesn't necessarily guarantee that the data you want is there.

It's similar to browser sniffing vs. feature detection in JavaScript, if you do any web development -- you should always just check to see if the feature you want to use exists, instead of trying to figure out which version of which browser is running your code and make assumptions about which features that version of that browser supports. Unfortunately, a lot of sites use browser sniffing, which leads to the endless "site X doesn't work in browser Y" problems.
__________________
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 » Featured Projects » oUF (Otravi Unit Frames) » how to track a weapon enchant proc with a tag


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