Page 1 of 1
How to check server/local time?
Posted: Mon May 14, 2012 8:02 am
by Edamh
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.
Re: How to check server/local time?
Posted: Mon May 14, 2012 8:16 am
by rock5
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
Re: How to check server/local time?
Posted: Mon May 14, 2012 9:22 am
by Edamh
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.
Re: How to check server/local time?
Posted: Mon May 14, 2012 9:35 am
by rock5
"> 11" is 12 or more. If you want to start at 11 it should be ">= 11" or "> 10". Otherwise the rest is good.