Originally Posted by Fizzlemizz
At 2 minutes remaining it starts adding the seconds to the diplsayd text (local hideSeconds = timetotrun >= 120).
Lua Code:
local Backdrop = { bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", } local frame_x = 0 local frame_y = -200 f = CreateFrame("Button", "ZAMROTimer", UIParent, "BackdropTemplate") f:SetWidth(255) f:SetHeight(20) f:SetBackdrop(Backdrop) f.text = f:CreateFontString(nil,"OVERLAY","GameTooltipText") f.text:SetTextHeight(15) f.text:SetPoint("CENTER") f:SetClampedToScreen(true) f:SetPoint("CENTER",UIParent,"CENTER",frame_x,frame_y) f:EnableMouse(true) f:SetMovable(true) f:RegisterForDrag("LeftButton") f:RegisterForClicks("AnyUp") f:Show() f:RegisterEvent("PLAYER_ENTERING_WORLD") f:SetScript("OnDragStart",function(this) this:StartMoving() end) f:SetScript("OnDragStop",function(this) this:StopMovingOrSizing() frame_x,frame_y = this:GetCenter() frame_x = frame_x - GetScreenWidth() / 2 frame_y = frame_y - GetScreenHeight() / 2 this:ClearAllPoints() this:SetPoint("CENTER",UIParent,"CENTER",frame_x,frame_y) end) local timeToRun = 5400 local function printTime(timetotrun) local hideSeconds = timetotrun >= 120 f.text:SetText(format("Next update in: %s", SecondsToTime(timetotrun, hideSeconds))) end local ticker = C_Timer.NewTicker(1, function() if timeToRun > 0 then timeToRun = timeToRun - 1 printTime(timeToRun) return end timeToRun = 5400 -- reset timer to 90 mins printTime(timeToRun) -- do whatever after 1 hour 30 end) printTime(timeToRun)
|
I need the event to start at a certain time
Code:
local communityFeastTime = {
["EU"] = 1679749200, -- 21:00
}
The event itself starts every 1.5 hours. Lasts 15 minutes
Code:
local feastTime = communityFeastTime[region]
if feastTime then
local currentTime = time()
local duration = 5400 -- 1.5hrs
local elapsed = mod(currentTime - feastTime, duration)
local nextTime = duration - elapsed + currentTime
addTitle(COMMUNITY_FEAST)
if currentTime - (nextTime-duration) < 900 then r,g,b = 0,1,0 else r,g,b = .6,.6,.6 end -- green text if progressing
GameTooltip:AddDoubleLine(date("%m/%d %H:%M", nextTime-duration*2), date("%m/%d %H:%M", nextTime-duration), .6,.6,.6, r,g,b)
GameTooltip:AddDoubleLine(date("%m/%d %H:%M", nextTime), date("%m/%d %H:%M", nextTime+duration), 1,1,1, 1,1,1)
end