How to check server/local time?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

How to check server/local time?

#1 Post by Edamh » Mon May 14, 2012 8:02 am

Did a search, but didn't find anything really relevant. I want to run specific waypoints or parts of waypoints only at specific times of the day. Is there a function that I can use to check what the time is -- either server or local? Thanks.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to check server/local time?

#2 Post by rock5 » Mon May 14, 2012 8:16 am

I use os.date with a "*t" argument.
http://www.lua.org/manual/5.1/manual.html#pdf-os.date
It returns a table with hour, minute etc values.

Example, to do something after 2:30 pm.

Code: Select all

local date = os.date("*t")
if date.hour > 14 and date.min > 30 then
    .... do something
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

Re: How to check server/local time?

#3 Post by Edamh » Mon May 14, 2012 9:22 am

rock5 wrote:I use os.date with a "*t" argument.
http://www.lua.org/manual/5.1/manual.html#pdf-os.date
It returns a table with hour, minute etc values.

Example, to do something after 2:30 pm.

Code: Select all

local date = os.date("*t")
if date.hour > 14 and date.min > 30 then
    .... do something
To check for between 11am and 11pm, would I setup something like?

Code: Select all

local date = os.date("*t")
if date.hour > 11 and 23 > date.hour  then
    .... do something
Thanks again.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to check server/local time?

#4 Post by rock5 » Mon May 14, 2012 9:35 am

"> 11" is 12 or more. If you want to start at 11 it should be ">= 11" or "> 10". Otherwise the rest is good.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests