So, now that the WoW API allows us to see time remaining until our PvP flag drops, I of course wanted it in PitBull... Adding it of course simply meant adding a DogTag for it, and DogTags are really well written so adding the new tag proved pretty easy.
DogTag:AddTag("Unit", "PVPRemaining", {
code = function(unit)
if unit == 'player' and IsPVPTimerRunning() then
local t = GetPVPTimer()/1000
if(t < 1) then
return nil
else
return t
end
else
return nil
end
end,
arg = {
'unit', 'string;undef', 'player'
},
ret = "number;nil",
events = "PVPRemaining#$unit",
doc = L["Return the time remaining until PVP flag expires"],
example = ('[PVPRemaining] => "110"; [PVPRemaining:FormatDuration] => "1:50"'),
category = L["Status"]
})
And I added this to DogTag:AddTimerHandler:
if IsPVPTimerRunning() then
DogTag:FireEvent("PVPRemaining", 'player')
end
Then I just added a text field with this DogTag in PitBull:
[PVPRemaining:FormatDuration]
Works great for me, I attached it the top right of my Player frame, inside, which puts it just next to the PvP Icon:
Yeah, in Status.lua there is currently a method that begins like this:
DogTag:AddTimerHandler("Unit", function(currentTime, num)
if first then
first = false
PARTY_MEMBERS_CHANGED()
end
for guid in pairs(offlineTimes) do
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
DogTag:FireEvent("OfflineDuration", unit)
end
end
Simply add the code like this:
DogTag:AddTimerHandler("Unit", function(currentTime, num)
if first then
first = false
PARTY_MEMBERS_CHANGED()
end
if IsPVPTimerRunning() then
DogTag:FireEvent("PVPRemaining", 'player')
end
for guid in pairs(offlineTimes) do
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
DogTag:FireEvent("OfflineDuration", unit)
end
end
This code is used to determine when Dogtags/Pitbull refreshes the count. There is no normal event associated with the count decreasing, so like other counters, I fake the event. This only applies to 'player' though, so I can simply fire it for them, no need to fire it for every unit.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Here's my ticket with the code:
http://www.wowace.com/projects/libdogtag-unit-3-0/tickets/6-pvp-remaining-timer-for-dogtags-pitbull/
And here's the code itself:
in Status.lua add:
And I added this to DogTag:AddTimerHandler:
Then I just added a text field with this DogTag in PitBull:
Works great for me, I attached it the top right of my Player frame, inside, which puts it just next to the PvP Icon:
Could you, please, explain this part more thoroughly if it's not too much trouble?
Simply add the code like this:
This code is used to determine when Dogtags/Pitbull refreshes the count. There is no normal event associated with the count decreasing, so like other counters, I fake the event. This only applies to 'player' though, so I can simply fire it for them, no need to fire it for every unit.