I'm trying to make a simple AddOn that keeps track of Flame Shock on my target. I know that I could just download another AddOn such as TellMeWhen or NeedToKnow etc. but I'm doing this for learning purposes. Anyway, any suggestions how I would do this? This is what I've got so far, but it doesn't work the way I want it to. It displays the remaining time of the debuff every time it ticks, but it doesn't tick at exactly every second, so for example it might display: 24.00001, 22.0003, 19.458... or something like that.
Code:
function RegisterEvents (self)
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
function EventHandler (self, event, ...)
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local playerGUID = UnitGUID("player")
local targetGUID = UnitGUID("target")
local timestamp, spellEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2 = ...
if sourceGUID == playerGUID and destGUID == targetGUID and (spellEvent == "SPELL_AURA_APPLIED" or spellEvent == "SPELL_PERIODIC_DAMAGE") then
local expirationTime = select(7, UnitAura("target", "Flame Shock", nil, "PLAYER|HARMFUL"))
if expirationTime then
FST_Main_FontString:SetText(expirationTime - GetTime())
else
FST_Main_FontString:SetText()
end
end
end
end
TL; DR: How do I make a timer that tracks Flame Shock and ticks every 1 second?
PS: English is not my native language so if I'm not making myself clear then don't hesitate to ask, I won't take offense.