Thread Tools Display Modes
07/21/14, 12:29 PM   #1
ZunaSW
Join Date: Mar 2014
Posts: 37
Set up an alarm at X time of the game?

Hello, sorry my english.
I want to set up an alarm when it is X time in the game (game time), for example, I want this alarm to be at 3:00 AM in the game. I don't really have idea of how to do it, I know there is not game time actually in the game, so I don't know if this is possible. I saw this library, but I don't know if it would do what I want, and if it does, how to do it: http://www.esoui.com/downloads/info53-AceTimer.html
Can anyone help me? : ) Thank you.
  Reply With Quote
07/21/14, 01:29 PM   #2
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
This is a simple timer. In programming the job of a timer is to run code after "X seconds have passed".
So it could help you to know that you have been logged in (on this char and not reloaded the UI) for X ammount of time.

We got 2 dedicated Clock addons. Look if they have a functionality like this:
http://www.esoui.com/downloads/info2...ndardTime.html
http://www.esoui.com/downloads/info232-TamrielTime.html

I am not sure how precise thier values or moon phase prediction really is.
  Reply With Quote
08/12/14, 11:07 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
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:
  1. -- call it on initialize & save the time you start playing --
  2. local function LogTime()
  3.     -- Capture start playing time --
  4.     myAddon.StartTime = GetSecondsSinceMidnight()
  5. end

You could then use the following and register it to some event that happens frequently so its checked often.
Lua Code:
  1. function myAddon.TimeAlert()
  2.     local iSecSinceMidnight = GetSecondsSinceMidnight()
  3.  
  4.     -- 3 am = 3 hours past midnight, 3 hours * 60 min/hour * 60 sec/min = 10800 seconds --
  5.    
  6.     -- If you start playing at 10pm we dont want the alarm going off yet, so we check the start time: --
  7.     -- (If you started playing After 3am) and (its earlier than you started playing, then its the next day) and (its after 3am now) --
  8.     -- or (you started playing before 3am) and (its now after 3am)
  9.     if (((myAddon.StartTime > 10800) and (iSecSinceMidnight < myAddon.StartTime) and (iSecSinceMidnight > 10800) ) or
  10.     ((myAddon.StartTime < 10800) and (iSecSinceMidnight > 10800))) then
  11.         -- do whatever you want your alarm to be --
  12.  
  13.         -- Create a window to pop-up, unhide it at 3am --
  14.         myAddon.popUpWindow:SetHidden(false)
  15.        
  16.         -- Display a chat Message --
  17.         d("It's 3 A.M.")
  18.        
  19.         -- Play some sound:  5 times, once every second to make sure you here it --
  20.         for i = 1, 5 do
  21.             zo_callLater(function() PlaySound(SOUNDS.GENERAL_ALERT_ERROR) end, (i*1000))
  22.         end
  23.     end
  24. 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:
  1. -- call it on initialize & get the time you start playing --
  2. function myAddon.LogTime()
  3.     -- Capture start playing time --
  4.     local iStartTimeSecs = GetTimeStamp()
  5.     local iAlertTime = 10800
  6.    
  7.     -- If you started after 3am --
  8.     if iStartTimeSecs > 10800 then
  9.         -- Calculate the number of seconds left in the day --
  10.         -- 24 hours/day * 60 min/hour * 60 sec/min = 86400 sec/day --
  11.         local iNumSecsTillMidnight = (86400 - iStartTimeSecs)
  12.         -- and add it to the number of seconds after midnight (for your alarm) --
  13.         iAlertTime = iAlertTime + iNumSecsTillMidnight
  14.     end
  15.  
  16.     -- I have no idea how accurate this would be or if it would even work over an extended period of time --
  17.     zo_callLater(function() myAddon.PlayAlert() end, (iAlertTime*1000))
  18. end
  19.  
  20. function myAddon.PlayAlert()
  21.     -- Do whatever, same as above --
  22. end

Last edited by circonian : 08/12/14 at 11:12 PM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Set up an alarm at X time of the game?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off