-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.lua
More file actions
executable file
·59 lines (50 loc) · 1.49 KB
/
Copy pathfunctions.lua
File metadata and controls
executable file
·59 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local ADDON_NAME, ns = ...
local L = ns.L
local CT = C_Timer
---
-- Local Functions
---
local function SecondsUntil()
return GetQuestResetTime() + 1
end
---
-- Namespaced Functions
---
--- Sets default options if they are not already set
function ns:SetOptionDefaults()
DRC_options = DRC_options or {}
for option, default in pairs(ns.data.defaults) do
ns:SetOptionDefault(DRC_options, option, default)
end
end
--- Set timers
function ns:SetTimers()
local secondsUntil = SecondsUntil()
-- Set Pre-Defined Alerts
for option, minutes in pairs(ns.data.timers) do
if secondsUntil >= (minutes * 60) then
CT.After(secondsUntil - (minutes * 60), function()
if ns:OptionValue(DRC_options, option) then
ns:ResetCheck()
end
end)
end
end
-- Restart the timer after the reset
CT.After(secondsUntil + 1, function()
ns:SetTimers()
end)
end
--- Checks the timer's state
function ns:ResetCheck()
local now = GetServerTime()
local secondsUntil = SecondsUntil()
local time = ns:TimeFormat(now + secondsUntil)
local message = "|cff" .. ns.color .. L.TimeString:format(ns:DurationFormat(DRC_options, secondsUntil), time) .. "|r"
if ns:OptionValue(DRC_options, "printText") then
print(message)
end
if ns:OptionValue(DRC_options, "raidwarning") then
RaidNotice_AddMessage(RaidWarningFrame, message, ChatTypeInfo["RAID_WARNING"])
end
end