Hi, i'm trying to edit/add formated times to my cooldown count, although im not getting anywhere anyone that could help out?
Lua Code:
local A, C, M, L = select(2, ...):unpack()
A.FormatTime = function(Seconds)
local Day, Hour, Minutes
Day, Hour, Minutes = 0, 0, 0
if Seconds >= 86400 then
Day = Seconds / 86400
Seconds = Seconds % 86400
end
if Seconds >= 3600 then
Hour = Seconds / 3600
Seconds = Seconds % 3600
end
if Seconds >= 60 then
Minutes = Seconds / 60
Seconds = Seconds % 60
end
if Day > 0 then
return format("%.2d:%.2d", Day, Hour)
elseif Hour > 0 then
return format("%.2d:%.2d", Hour, Minutes)
elseif Minutes > 0 then
return format("%.2d:%.2d", Minutes, Seconds)
else
if Seconds < 10 then
return format("%.1f", Seconds)
else
return format("%d", Seconds)
end
end
end
local function CooldownCountUpdate(self)
local Now, Start, Duration = GetTime(), self:GetCooldownTimes()
Start, Duration = Start/1000, Duration/1000
local Elapsed = Now - Start
local TimeLeft = math.max(0, Duration - Elapsed)
local NumRegions = self:GetNumRegions()
for i = 1, NumRegions do
local Region = select(i, self:GetRegions())
if (Region.GetText) then
if (TimeLeft <= 10) then
Region:SetTextColor(1, 0, 0)
elseif (TimeLeft <= 30) then
Region:SetTextColor(1, 0.42, 0)
elseif (TimeLeft <= 60) then
Region:SetTextColor(1, 0.82, 0)
else
Region:SetTextColor(unpack(C.Cooldowns.TextColor))
end
--local TimeText = A.FormatTime() -- Not quite sure how to make it work
--Region:SetText(TimeText)
end
end
end
hooksecurefunc("CooldownFrame_Set", function(self, start, duration, enable, forceShowDrawEdge, modRate)
local CooldownCount = GetCVar("countdownForCooldowns")
if (CooldownCount and not self.IsCooldownEdited) then
local NumRegions = self:GetNumRegions()
self:SetFrameStrata("HIGH")
self:HookScript("OnUpdate", CooldownCountUpdate)
for i = 1, NumRegions do
local Region = select(i, self:GetRegions())
if (Region.GetText) then
Region:SetPoint("CENTER", 1, 0)
Region:SetFontTemplate(C.Media.Font2, C.Cooldowns.FontSize)
end
end
self.IsCooldownEdited = true
end
end)
Cheers!