View Single Post
03-14-24, 01:14 PM   #17
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,892
I wasn't going to but...
Your numbers still dont add up
Code:
Session Start (6 hours):
(line 0) Time 06:00 - Sub-Session B -- + 60 min = 07:00 (120 minutes until next event)
(line 1) Time 07:00 - Sub-Session B - + 60 min = 08:00 (60 minutes until next event)
(line 2) Time 08:00 - Sub-Session А -- Event for 4 minutes. 08:00 + 4 min = 08:04 (56 minutes until next event)
(line 3) Time 09:00 - Sub-Session А -- Event for 4 minutes. 09:00 + 4 min = 09:04 (56 minutes until next event)
(line 4) Time 10:00 - Sub-Session А -- Event for 4 minutes. 10:00 + 4 min = 10:04 (176 minutes until next event)
Session End:
60+60+4+56+4+56+4+176 = 420 (7 hours).

But again using some guesswork (116 is instead of 176) the explanation seems to look like this (I'm starting to feel like ChatGPT, just keep saying something even if you don't understand the request ):
  • 6 hour repeating session
  • 4 minute event runs 3 times begining at startTime, then 60 minutes apart for a total duration of 2 hours and 4 minutes (Sub-session A)(4 + 56 + 4 + 56 + 4).
  • Followed by 3 hours 56 minutes waiting (Sub-session B)

2:04 + 3:56 (Sub-session A + Sub-session B) make up each 6 hour session. Then repeat.

(I've included some test times to run over 6 minutes instead of 6 hours. To use, remove the --[[ directly above the replacement times and remove the ]]-- directly below them. Put them back or delete the test times to use the 6 hour rotation.

The * shows you are in the 3:56 waiting period.

If this is it then you will have to find a startTime where the first of the 4 minute events starts on a day in your region and replace 1709615040 with that time.

Lua Code:
  1. local addonName, addon = ...
  2. local L, MyRegion
  3. local RegionTimes = {
  4.     [1] = {
  5.         startTime = 1709615040,
  6.         totalDuration = 21600, -- complete session time 6 hours repeating
  7.         A = { -- sub-session -- event runs 3 times
  8.             duration = 7440, -- 2 hours 4 minutes
  9.             interval = 3600, -- runs every 1 hour (56 minutes wait time)
  10.             eventtime = 240, -- 4 minutes run time
  11.         },
  12.         B = { -- sub-session -- just waiting.
  13.             duration = 14160, -- 3 hours 56 minutes
  14.         },
  15.     },
  16. }
  17.  
  18. --[[ TEST TIMES ONLY: over 6 minutes instead of 6 hours ]]--
  19.  
  20. --[[
  21. RegionTimes[1].totalDuration = 360 -- 6 minutes
  22. RegionTimes[1].A.duration = 124 -- 2 minutes 4 seconds
  23. RegionTimes[1].A.interval = 60 -- 1 minute
  24. RegionTimes[1].A.eventtime = 4 -- 4 seconds
  25.  
  26. RegionTimes[1].B.duration = 236 -- 3 minute 56 seconds
  27. ]]--
  28.  
  29. --[[ END TEST TIMES ]]--
  30.  
  31. local Localizations = {
  32.     enUS = {
  33.         Waiting = "|c1C7BCEFFEvent:%s\nbefore the start: %s%s|r",
  34.         Running = "|cFF35BE21Event:%s\n%s%s until completion|r",
  35.     },
  36. }
  37.  
  38. ------------------------------------------------------------------------------------------------------
  39. -- These might be converted to Saved Variables so each character can determine
  40. -- wether or not to play a sound, the alert times and colors and sound to play.
  41. -- If so then most of the code below will have to move into an event handler for
  42. -- the PLAYER_LOGIN or PLAYER_ENTERING_WORLD event.
  43. local defaults = {
  44.     useColor = true,
  45.     useSound = true,
  46.     alert1 = 600, -- Alarm 1 set to 10 minutes before event
  47.     alert1Color = "|cffffff00", -- Yellow
  48.     alert2 = 300, -- Alarm 2 set to 5 minutes before event
  49.     alert2Color = "|cffff0000", -- Red
  50.     soundKit = 32585, -- Alarm sound
  51. }
  52.  
  53. ------------------------------------------------------------------------------------------------------
  54. local function CalcTime(starttime, servertime, duration, interval)
  55.     local timeToEvent = (starttime - servertime) % interval
  56.     local inEvent, timeToRun
  57.     if timeToEvent > (interval - duration) then -- Is there between 1:15 and 1:30 to go? If so, we're in the event
  58.         inEvent = true
  59.         timeToRun = duration - (interval - timeToEvent)
  60.     else                    -- Otherwise, set the timer to time to next event
  61.         inEvent = false
  62.         timeToRun = timeToEvent
  63.     end
  64.     return inEvent, timeToRun
  65. end
  66.  
  67. local function printTime(self)
  68.     local serverTime = GetServerTime()
  69.     -- Calculate remaining time in current cycle
  70.     local remainingTime = (MyRegion.startTime - serverTime) % MyRegion.totalDuration
  71.     local longWait = ""
  72.     local inEvent
  73.     if remainingTime > RegionTimes[1].B.duration then -- in Session A time
  74.     inEvent, remainingTime = CalcTime(MyRegion.startTime, serverTime, MyRegion.A.eventtime, MyRegion.A.interval)
  75.     else -- in Session B time
  76.     longWait = "|cffffff00*|r"
  77.     end
  78.     local hideSeconds = remainingTime >= 120
  79.     local msg = L.Waiting
  80.     local msgColor = "|cffffffff"
  81.     if inEvent then
  82.         msg = L.Running
  83.     else
  84.         if defaults.useColor and remainingTime <= defaults.alert2 then
  85.             msgColor = defaults.alert2Color
  86.         elseif remainingTime <= defaults.alert1 then
  87.             if defaults.useSound and not self.Alerted then
  88.                 self.Alerted = true
  89.                 PlaySound(defaults.soundKit, "Master")
  90.             end
  91.             if defaults.useColor then
  92.                 msgColor = defaults.alert1Color
  93.             end
  94.         end
  95.     end
  96.     self.Text:SetText(format(msg, longWait, msgColor, SecondsToTime(remainingTime, false)))
  97. end
  98.  
  99. ------------------------------------------------------------------------------------------------------
  100. local Backdrop = {
  101.     bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
  102. }
  103.  
  104. local frame_x = 100    
  105. local frame_y = -250    
  106. local f = CreateFrame("Button", "ZAMTimer777", UIParent, "BackdropTemplate")
  107. f:SetWidth(255)                                          
  108. f:SetHeight(30)
  109. f:SetPoint("CENTER")
  110. f:SetBackdrop(Backdrop)
  111. f:SetClampedToScreen(true)
  112. f:EnableMouse(true)
  113. f:SetMovable(true)
  114. f:SetUserPlaced(true)
  115. f:RegisterForDrag("LeftButton")
  116. f:RegisterForClicks("AnyUp")
  117. f.Text = f:CreateFontString(nil, "OVERLAY", "GameTooltipText")
  118. f.Text:SetPoint("CENTER")
  119. f.Elapsed = 0 -- Set starting timeout (0 second)
  120. f:SetScript("OnDragStart",function(self)
  121.     self:StartMoving()
  122. end)
  123. f:SetScript("OnDragStop",function(self)  
  124.     self:StopMovingOrSizing()
  125. end)
  126. f:RegisterEvent("PLAYER_LOGIN")
  127. f:SetScript("OnEvent", function(self)
  128.     local locale = GetLocale()
  129.     L = Localizations[locale] or Localizations.enUS -- Default to enUS if locale doesn't exist in the table
  130.     MyRegion = RegionTimes[GetCurrentRegion()] or RegionTimes[1] -- Default to region 1 (US) if it doesn't exist in the table
  131.     self:SetScript("OnUpdate", function(self, elapsed)
  132.     self.Elapsed = self.Elapsed - elapsed
  133.     if self.Elapsed > 0 then -- Only check once per second
  134.         return
  135.     end
  136.     self.Elapsed = 1 -- reset the timeout (we've counted down 1 second)
  137.     printTime(self)
  138.     end)
  139. end)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-14-24 at 04:33 PM.
  Reply With Quote