Go to Page... |
Thread Tools | Display Modes |
02-15-24, 05:41 AM | #1 |
Timer with an interval of 1 hour and 30 minutes
Hi. I was able to make a timer. But I can't figure out how to make it with an interval of 1 hour and 30 minutes.
Code:
local frame_x = 0 local frame_y = -200 f = CreateFrame("Button", "ZAMROTimer", UIParent, "UIDropDownMenuTemplate") f:SetWidth(255) f:SetHeight(20) f.text = f:CreateFontString(nil,"OVERLAY","GameTooltipText") f.text:SetTextHeight(15) f.text:SetAllPoints(f) 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) ---------------------------------------------------------------- if (not Region) then Region={} end ---------------------------------------------------------------- local w = "|cffffffff" local o = "|cff00ff00" ---------------------------------------------------------------- local M, H, D, S, ZAM, ZAMROlasts, reg, reg2, info, unkForm, ZAMROUnc, ZAMROlastsUnc if GetLocale() == "ruRU" then M = "м " H = "ч " D = "д " S = "с" ZAM = "|cffFFFF33Большое Пиршество: " ZAMROUnc = "" ZAMROlastsUnc = "" reg = "" reg2 = "" info = "" unkForm = "" relDate = "" else M = "m " H = "h " D = "d " S = "s" ZAM = "|cffFFFF33Community Feast: " ZAMROUnc = "" ZAMROlastsUnc = "" reg = "" reg2 = "" info = "" unkForm = "" relDate = "" end ---------------------------------------------------------------- local function ZAMROTimerCOMMAND(msg, editbox) msg = msg:lower() if msg == "eu" then DEFAULT_CHAT_FRAME:AddMessage("|cffff8a00ZAMROTimer|r: "..reg.." |cff00ff00EU |cffdcdcdc(CET)") Region = {"EU"} else DEFAULT_CHAT_FRAME:AddMessage("|cffff8a00ZAMROTimer|r: "..unkForm) end end SlashCmdList["ZAMROTimer"] = ZAMROTimerCOMMAND ---------------------------------------------------------------- local menu = { { text = reg2, notCheckable = true, isTitle = true}, { text = "|cff00ff00EU |cffdcdcdc(CET)", notCheckable = true, func = function() DEFAULT_CHAT_FRAME:AddMessage("|cffff8a00ZAMROTimer|r: "..reg.." |cff00ff00EU |cffdcdcdc(CET)") Region = {"EU"} end }, { text = info, notCheckable = true, func = function() ZAMTimeInfoMSG() end }, } ---------------------------------------------------------------- f:SetScript("OnUpdate",function(this) local ZAMRO_release = 1707996600 if Region[1] == "EU" then ZAMRO_release = 1707996600 end ---------------------------------------------------------------- local MP_D, MP_Hr, MP_M, MP_S, ZAMROTime_MP if time() <= ZAMRO_release then MP_D = floor((ZAMRO_release-time())/86400) MP_H = floor(((ZAMRO_release-time())-(MP_D*86400))/1440) MP_M = floor(((ZAMRO_release-time())-((MP_D*86400)+(MP_H*1440)))/60) MP_S = floor((ZAMRO_release-time())-((MP_D*86400)+(MP_H*1440)+(MP_M*60))) ZAMROTime_MP = ZAM..o..MP_D..w..D..o..MP_H..w..H..o..MP_M..w..M..o..MP_S..w..S ZAMROTime_MP_Report = ZAMROUnc..MP_D..D..MP_H..H..MP_M..M..MP_S..S else MP_D = floor((time()-ZAMRO_release)/85500) MP_H = floor(((time()-ZAMRO_release)-(MP_D*85500))/1440) MP_M = floor(((time()-ZAMRO_release)-((MP_D*85500)+(MP_H*1440)))/60) MP_S = floor((time()-ZAMRO_release)-((MP_D*85500)+(MP_H*1440)+(MP_M*60))) ZAMROTime_MP = ZAM..o..MP_D..w..D..o..MP_H..w..H..o..MP_M..w..M..o..MP_S..w..S ZAMROTime_MP_Report = ZAMROlastsUnc..MP_D..D..MP_H..H..MP_M..M..MP_S..S end function ZAMTimeInfoMSG() DEFAULT_CHAT_FRAME:AddMessage("|cffff8a00ZAMROTimer|r: "..ZAMROTime_MP) DEFAULT_CHAT_FRAME:AddMessage("|cffff8a00ZAMROTimer|r: "..reg2.." |cff00ff00"..Region[1]) DEFAULT_CHAT_FRAME:AddMessage("|cffff8a00ZAMROTimer|r: "..relDate.."|cff00ff00"..date("%X %d.%m.%Y",ZAMRO_release)) end ---------------------------------------------------------------- this.text:SetText(ZAMROTime_MP) end) ---------------------------------------------------------------- f:SetScript("OnClick",function(self,button,down) if button == "RightButton" then EasyMenu(menu, f, "cursor", 0,0, "MENU") end if ((button == "LeftButton") and (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then if ChatEdit_GetActiveWindow() then ChatEdit_GetActiveWindow():Insert(ZAMROTime_MP_Report) end end end) f:Click("RightButton") |
|
02-15-24, 06:52 AM | #2 |
There is a Timer system in wow.
https://warcraft.wiki.gg/wiki/API_C_Timer.After With 2 other options depending on requirements. There are some code examples in there so hopefully you will see how it can work for your task.
__________________
Characters: Gwynedda - 70 - Demon Warlock Galaviel - 70 - Resto Druid Gamaliel - 70 - Disc Priest Lienae - 70 - Resto Shaman Velandryn - 70 - Prot Paladin (TR) + 5 at 60+ + 2 at 40+ Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818 |
|
02-15-24, 07:30 AM | #3 | |
|
||
02-15-24, 07:57 AM | #4 |
I've never used it myself. But I would have thought the example they gave was informative enough.
Lua Code:
This example is a timer of 1 second that calls itself making it a repeating timer. Inside that function you could have it do what you want so that every 1 second ( in this example ) it will redo them. This can even be another function where you do all the functionality.
__________________
Characters: Gwynedda - 70 - Demon Warlock Galaviel - 70 - Resto Druid Gamaliel - 70 - Disc Priest Lienae - 70 - Resto Shaman Velandryn - 70 - Prot Paladin (TR) + 5 at 60+ + 2 at 40+ Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818 Last edited by Xrystal : 02-15-24 at 08:01 AM. |
|
02-15-24, 08:33 AM | #5 | |
I don't understand how to insert this code into mine so that the time is displayed. I've tried different ways, but the timer doesn't show up if I change the code. |
||
02-15-24, 10:28 AM | #6 |
What exactly were you hoping to do ?
Maybe knowing what you wanted to happen when the timer triggers every 1 hr 30 minutes would let us know what part of your code is and isn't necessary with access to the timer functions.
__________________
Characters: Gwynedda - 70 - Demon Warlock Galaviel - 70 - Resto Druid Gamaliel - 70 - Disc Priest Lienae - 70 - Resto Shaman Velandryn - 70 - Prot Paladin (TR) + 5 at 60+ + 2 at 40+ Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818 Last edited by Xrystal : 02-15-24 at 10:31 AM. |
|
02-15-24, 10:29 PM | #7 | |
Code:
if time() <= ZAMRO_release then MP_D = floor((ZAMRO_release-time())/86400) MP_H = floor(((ZAMRO_release-time())-(MP_D*86400))/1440) MP_M = floor(((ZAMRO_release-time())-((MP_D*86400)+(MP_H*1440)))/60) MP_S = floor((ZAMRO_release-time())-((MP_D*86400)+(MP_H*1440)+(MP_M*60))) ZAMROTime_MP = ZAM..o..MP_D..w..D..o..MP_H..w..H..o..MP_M..w..M..o..MP_S..w..S ZAMROTime_MP_Report = ZAMROUnc..MP_D..D..MP_H..H..MP_M..M..MP_S..S else MP_D = floor((time()-ZAMRO_release)/85500) MP_H = floor(((time()-ZAMRO_release)-(MP_D*85500))/1440) MP_M = floor(((time()-ZAMRO_release)-((MP_D*85500)+(MP_H*1440)))/60) MP_S = floor((time()-ZAMRO_release)-((MP_D*85500)+(MP_H*1440)+(MP_M*60))) ZAMROTime_MP = ZAM..o..MP_D..w..D..o..MP_H..w..H..o..MP_M..w..M..o..MP_S..w..S ZAMROTime_MP_Report = ZAMROlastsUnc..MP_D..D..MP_H..H..MP_M..M..MP_S..S end |
||
02-15-24, 11:55 PM | #8 |
At 2 minutes remaining it starts adding the seconds to the diplsayd text (local hideSeconds = timetotrun >= 120).
Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-15-24 at 11:58 PM. |
|
02-16-24, 12:46 AM | #9 | |
Code:
local communityFeastTime = { ["EU"] = 1679749200, -- 21:00 } 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 |
||
02-16-24, 12:54 AM | #10 |
You could use time() in the ticker (or an OnUpdate) and once it reaches the assigned time change over to using the countdown.
You can cancel a ticker and start a new one if you want seperate processes
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-16-24 at 01:02 AM. |
|
02-16-24, 01:08 AM | #11 | |
Code:
local communityFeastTime = { ["EU"] = 1679749200, -- 21:00 } |
||
02-16-24, 03:21 AM | #12 |
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:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-16-24 at 03:27 AM. |
|
02-16-24, 05:06 AM | #13 | |
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 |
||
02-16-24, 09:44 AM | #14 |
I'm not sure I understand the question. Does the "the event is underway" message last for 15 minutes after the event starts or does it appear 15 minutes after the event starts (seems a bit strange but...) and if so how long does it last? You need to be specific about what you want to happen when.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-16-24 at 12:08 PM. |
|
02-16-24, 10:24 PM | #15 | |
01:00 02:30 04:00 05:30 07:00 08:30 10:00 11:30 13:00 14:30 16:00 17:30 19:00 20:30 22:00 23:30 2. The event always runs for 15 minutes. Here is the start and end cycle of the event. 01:15 02:45 04:15 05:45 07:15 08:45 10:15 11:45 13:15 14:45 16:15 17:45 19:15 20:45 22:15 23:45 Now the inscription is displayed all the time - Next update in, it is necessary that while the event is going on (these are the 15 minutes), instead of Next update in, there should be an an event in progress inscription. Last edited by Hubb777 : 02-16-24 at 10:29 PM. |
||
02-16-24, 11:44 PM | #16 |
Try:
Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-17-24 at 09:49 AM. |
|
02-17-24, 01:22 AM | #17 | |
UPD: I edited the code and replaced 120 with 0. The problem is that after completing the 15 minute timer, it started counting down 1.5 hours to the next event. Although there should be 1 hour and 15 minutes left. The interval between events is 1 hour and 15 minutes. The event lasts for 15 minutes. For example: the event started at 10:00, ended at 10:15, after that the timer should show that the next event is at 11:30, and this code shows that the event will be at 11:45 (and it needs to be at 11:30) This is fixed by the command /reload - as I understand it, the timer time is not reset every time. Is that why you have to prescribe? Code:
local addonName, addon = ... 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 function printTime(timetotrun, inevent) local hideSeconds = timetotrun >= 0 local msg = "Next event is in: %s" if inevent then msg = "%s until event ends" end f.text:SetText(format(msg, SecondsToTime(timetotrun, hideSeconds))) end local communityFeastTime = { -- Known region start time(s) ["EU"] = 46800, -- 21:00 in seconds ie. (21 * 60 * 60) } local eventTime = 15 * 60 -- Time the event runs in seconds(15 mins) local waitTime = 90 * 60 -- Time between events in seconds (90 mins) local inEvent, timeToRun local startTime = communityFeastTime.EU -- Start time from the table local timeNow = date("*t", time()) -- The time at login local timeToSeconds = ((timeNow.hour * 60) * 60) + (timeNow.min * 60) + timeNow.sec -- Convert time now to seconds local timeToEvent = (startTime - timeToSeconds) % waitTime -- Remaining time before next event starts if timeToEvent > (waitTime - eventTime) then -- Is there between 1:15 and 1:30 to go? If so, we're in the event inEvent = true timeToRun = waitTime - timeToEvent else -- Otherwise, set the ticker timer to time to next event inEvent = false timeToRun = timeToEvent end local ticker = C_Timer.NewTicker(1, function() if timeToRun > 0 then timeToRun = timeToRun - 1 printTime(timeToRun, inEvent) return end if inEvent then -- The event is in progress inEvent = false timeToRun = waitTime -- Reset ticker timer to 90 mins else -- Waiting for the next event inEvent = true timeToRun = eventTime end printTime(timeToRun, inEvent) end) printTime(timeToRun, inEvent) Last edited by Hubb777 : 02-17-24 at 04:23 AM. |
||
02-17-24, 09:40 AM | #18 |
The time between the events is 90 minutes for the login test but once you've started the clock it's then reduced by 15 minutes (the time the event takes) which I didn't account for.
The ticker code would be: Lua Code:
Also fixed in my previous post.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-17-24 at 09:49 AM. |
|
02-17-24, 10:29 PM | #19 | |
1708234200 Maybe these parts of the code will help Code:
eFrame.regionEventStartTime = v.regionEventStartTime[GetCurrentRegion()] Code:
local start_timestamp = GetServerTime() - self.regionEventStartTime local next_event = self.eventIntervalInSeconds - start_timestamp % self.eventIntervalInSeconds local spawning = self.eventIntervalInSeconds - next_event < self.eventDuration local remaining = self.eventDuration - (self.eventIntervalInSeconds - next_event) local showedTime = spawning and remaining or next_event Code:
regionEventStartTime = { [1] = 16862400102,}, -- eu eventDuration = 900, eventIntervalInSeconds = 5400, enable = true, datablock = {} }, Last edited by Hubb777 : 02-17-24 at 10:48 PM. |
||
02-17-24, 11:20 PM | #20 |
Your regionEventStartTime table is broken so I made what I think it might be intended to look like.
EDIT: My math foo is broken. Fixed the calculation if you logged in while the event is in progress. As in (not very different): Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-18-24 at 12:28 AM. |
|
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Timer with an interval of 1 hour and 30 minutes |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|