View Single Post
02-16-24, 12:46 AM   #9
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 122
Originally Posted by Fizzlemizz View Post
At 2 minutes remaining it starts adding the seconds to the diplsayd text (local hideSeconds = timetotrun >= 120).

Lua Code:
  1. local Backdrop = {
  2.     bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
  3. }
  4.  
  5. local frame_x = 0      
  6. local frame_y = -200    
  7. f = CreateFrame("Button", "ZAMROTimer", UIParent, "BackdropTemplate")
  8. f:SetWidth(255)                                            
  9. f:SetHeight(20)
  10. f:SetBackdrop(Backdrop)
  11. f.text = f:CreateFontString(nil,"OVERLAY","GameTooltipText")
  12. f.text:SetTextHeight(15)
  13. f.text:SetPoint("CENTER")
  14. f:SetClampedToScreen(true)
  15. f:SetPoint("CENTER",UIParent,"CENTER",frame_x,frame_y)
  16. f:EnableMouse(true)
  17. f:SetMovable(true)
  18. f:RegisterForDrag("LeftButton")
  19. f:RegisterForClicks("AnyUp")
  20. f:Show()
  21. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  22. f:SetScript("OnDragStart",function(this)
  23.    this:StartMoving()
  24. end)
  25. f:SetScript("OnDragStop",function(this)  
  26.    this:StopMovingOrSizing()
  27.    frame_x,frame_y = this:GetCenter()
  28.    frame_x = frame_x - GetScreenWidth() / 2
  29.    frame_y = frame_y - GetScreenHeight() / 2
  30.    this:ClearAllPoints()
  31.    this:SetPoint("CENTER",UIParent,"CENTER",frame_x,frame_y)
  32. end)
  33. local timeToRun = 5400
  34. local function printTime(timetotrun)
  35.     local hideSeconds = timetotrun >= 120
  36.     f.text:SetText(format("Next update in: %s", SecondsToTime(timetotrun, hideSeconds)))
  37. end
  38. local ticker = C_Timer.NewTicker(1, function()
  39.    if timeToRun > 0 then
  40.       timeToRun = timeToRun - 1
  41.       printTime(timeToRun)
  42.       return
  43.    end
  44.    timeToRun = 5400 -- reset timer to 90 mins
  45.    printTime(timeToRun)
  46.    -- do whatever after 1 hour 30
  47. end)
  48. 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
  Reply With Quote