There are a bunch of functions for getting time in the game. Look at the API under the global section:
http://wiki.esoui.com/API#Global
I didn't test any of this -- But it should point you in the right direction
You could call a function on intialize to get the time you start playing. Needed to check and see if you started playing before 3am or after 3am.
Lua Code:
-- call it on initialize & save the time you start playing --
local function LogTime()
-- Capture start playing time --
myAddon.StartTime = GetSecondsSinceMidnight()
end
You could then use the following and register it to some event that happens frequently so its checked often.
Lua Code:
function myAddon.TimeAlert()
local iSecSinceMidnight = GetSecondsSinceMidnight()
-- 3 am = 3 hours past midnight, 3 hours * 60 min/hour * 60 sec/min = 10800 seconds --
-- If you start playing at 10pm we dont want the alarm going off yet, so we check the start time: --
-- (If you started playing After 3am) and (its earlier than you started playing, then its the next day) and (its after 3am now) --
-- or (you started playing before 3am) and (its now after 3am)
if (((myAddon.StartTime > 10800) and (iSecSinceMidnight < myAddon.StartTime) and (iSecSinceMidnight > 10800) ) or
((myAddon.StartTime < 10800) and (iSecSinceMidnight > 10800))) then
-- do whatever you want your alarm to be --
-- Create a window to pop-up, unhide it at 3am --
myAddon.popUpWindow:SetHidden(false)
-- Display a chat Message --
d("It's 3 A.M.")
-- Play some sound: 5 times, once every second to make sure you here it --
for i = 1, 5 do
zo_callLater(function() PlaySound(SOUNDS.GENERAL_ALERT_ERROR) end, (i*1000))
end
end
end
You could also do what was suggested & take that same information & do a timer. I've never messed with anything like that except timing something for a few seconds. I don't know how accurate a zo_callLater would be for an extended period of time or if it has a time limit on it
(it may not work if set for several hours I have no clue). Theres probably a better way to set a timer, but the rest of it should point you in the right direction to get the information you need to set a timer.
Lua Code:
-- call it on initialize & get the time you start playing --
function myAddon.LogTime()
-- Capture start playing time --
local iStartTimeSecs = GetTimeStamp()
local iAlertTime = 10800
-- If you started after 3am --
if iStartTimeSecs > 10800 then
-- Calculate the number of seconds left in the day --
-- 24 hours/day * 60 min/hour * 60 sec/min = 86400 sec/day --
local iNumSecsTillMidnight = (86400 - iStartTimeSecs)
-- and add it to the number of seconds after midnight (for your alarm) --
iAlertTime = iAlertTime + iNumSecsTillMidnight
end
-- I have no idea how accurate this would be or if it would even work over an extended period of time --
zo_callLater(function() myAddon.PlayAlert() end, (iAlertTime*1000))
end
function myAddon.PlayAlert()
-- Do whatever, same as above --
end