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:
local addonName, addon = ...
local L, MyRegion
local RegionTimes = {
[1] = {
startTime = 1709615040,
totalDuration = 21600, -- complete session time 6 hours repeating
A = { -- sub-session -- event runs 3 times
duration = 7440, -- 2 hours 4 minutes
interval = 3600, -- runs every 1 hour (56 minutes wait time)
eventtime = 240, -- 4 minutes run time
},
B = { -- sub-session -- just waiting.
duration = 14160, -- 3 hours 56 minutes
},
},
}
--[[ TEST TIMES ONLY: over 6 minutes instead of 6 hours ]]--
--[[
RegionTimes[1].totalDuration = 360 -- 6 minutes
RegionTimes[1].A.duration = 124 -- 2 minutes 4 seconds
RegionTimes[1].A.interval = 60 -- 1 minute
RegionTimes[1].A.eventtime = 4 -- 4 seconds
RegionTimes[1].B.duration = 236 -- 3 minute 56 seconds
]]--
--[[ END TEST TIMES ]]--
local Localizations = {
enUS = {
Waiting = "|c1C7BCEFFEvent:%s\nbefore the start: %s%s|r",
Running = "|cFF35BE21Event:%s\n%s%s until completion|r",
},
}
------------------------------------------------------------------------------------------------------
-- These might be converted to Saved Variables so each character can determine
-- wether or not to play a sound, the alert times and colors and sound to play.
-- If so then most of the code below will have to move into an event handler for
-- the PLAYER_LOGIN or PLAYER_ENTERING_WORLD event.
local defaults = {
useColor = true,
useSound = true,
alert1 = 600, -- Alarm 1 set to 10 minutes before event
alert1Color = "|cffffff00", -- Yellow
alert2 = 300, -- Alarm 2 set to 5 minutes before event
alert2Color = "|cffff0000", -- Red
soundKit = 32585, -- Alarm sound
}
------------------------------------------------------------------------------------------------------
local function CalcTime(starttime, servertime, duration, interval)
local timeToEvent = (starttime - servertime) % interval
local inEvent, timeToRun
if timeToEvent > (interval - duration) then -- Is there between 1:15 and 1:30 to go? If so, we're in the event
inEvent = true
timeToRun = duration - (interval - timeToEvent)
else -- Otherwise, set the timer to time to next event
inEvent = false
timeToRun = timeToEvent
end
return inEvent, timeToRun
end
local function printTime(self)
local serverTime = GetServerTime()
-- Calculate remaining time in current cycle
local remainingTime = (MyRegion.startTime - serverTime) % MyRegion.totalDuration
local longWait = ""
local inEvent
if remainingTime > RegionTimes[1].B.duration then -- in Session A time
inEvent, remainingTime = CalcTime(MyRegion.startTime, serverTime, MyRegion.A.eventtime, MyRegion.A.interval)
else -- in Session B time
longWait = "|cffffff00*|r"
end
local hideSeconds = remainingTime >= 120
local msg = L.Waiting
local msgColor = "|cffffffff"
if inEvent then
msg = L.Running
else
if defaults.useColor and remainingTime <= defaults.alert2 then
msgColor = defaults.alert2Color
elseif remainingTime <= defaults.alert1 then
if defaults.useSound and not self.Alerted then
self.Alerted = true
PlaySound(defaults.soundKit, "Master")
end
if defaults.useColor then
msgColor = defaults.alert1Color
end
end
end
self.Text:SetText(format(msg, longWait, msgColor, SecondsToTime(remainingTime, false)))
end
------------------------------------------------------------------------------------------------------
local Backdrop = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
}
local frame_x = 100
local frame_y = -250
local f = CreateFrame("Button", "ZAMTimer777", UIParent, "BackdropTemplate")
f:SetWidth(255)
f:SetHeight(30)
f:SetPoint("CENTER")
f:SetBackdrop(Backdrop)
f:SetClampedToScreen(true)
f:EnableMouse(true)
f:SetMovable(true)
f:SetUserPlaced(true)
f:RegisterForDrag("LeftButton")
f:RegisterForClicks("AnyUp")
f.Text = f:CreateFontString(nil, "OVERLAY", "GameTooltipText")
f.Text:SetPoint("CENTER")
f.Elapsed = 0 -- Set starting timeout (0 second)
f:SetScript("OnDragStart",function(self)
self:StartMoving()
end)
f:SetScript("OnDragStop",function(self)
self:StopMovingOrSizing()
end)
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self)
local locale = GetLocale()
L = Localizations[locale] or Localizations.enUS -- Default to enUS if locale doesn't exist in the table
MyRegion = RegionTimes[GetCurrentRegion()] or RegionTimes[1] -- Default to region 1 (US) if it doesn't exist in the table
self:SetScript("OnUpdate", function(self, elapsed)
self.Elapsed = self.Elapsed - elapsed
if self.Elapsed > 0 then -- Only check once per second
return
end
self.Elapsed = 1 -- reset the timeout (we've counted down 1 second)
printTime(self)
end)
end)