View Single Post
02-16-24, 05:06 AM   #13
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
The math might be a bit sketchy and long winded to show the "what" of it so test it but something like:
I don't know the event so I'm assuming the event is runs every 1.5 hours of the day and the start time (21:00) is the "known" time one of the events happens each day in that region (EU). If it's something else like the event only runs from 21:00 to 24:00 then this is not what you're looking for.

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.  
  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 communityFeastTime = {
  39.     ["EU"] = 75600, -- 21:00 in seconds ie. (21 * 60 * 60)
  40. }
  41.  
  42. local startTime = communityFeastTime.EU -- start time from the table
  43. local t = date("*t", time()) -- the time now
  44. local timeToSeconds = ((t.hour * 60) * 60) + (t.min * 60) + t.sec -- convert time now to seconds
  45. local timeToEvent = (startTime - timeToSeconds) % 5400 -- remaining time before next event starts
  46. local timeToRun = timeToEvent -- set the ticker timer to time to next event
  47. local ticker = C_Timer.NewTicker(1, function()
  48.    if timeToRun > 0 then
  49.       timeToRun = timeToRun - 1
  50.       printTime(timeToRun)
  51.       return
  52.    end
  53.    timeToRun = 5400 -- reset ticker timer to 90 mins
  54.    printTime(timeToRun)
  55.    -- do whatever after 1 hour 30
  56. end)
  57. printTime(timeToRun)
Yes, it works great. You've helped me a lot. You are the best!!!

Another question is can I add another line to the variable?

1. So that after the start of the event, within 15 minutes (900 seconds), there is another message "the event is underway".
I understand this can be done through, but how?

Code:
eventDuration = 900
  Reply With Quote