Rollover

Pazleysox

Member
I've been looking around for an ash command that will return what time rollover happens.

MrEdge73's script has "MinutesToRollover()", but I know that command doesn't work anymore. He also has the command "WaitMinutes()", and I know that doesn't work either.

I can type /rollover into the CLI, and get an accurate time, but can't use that in a script. Is there something I'm missing, or was this just taken out?
 

Crowther

Active member
The functions you need are rollover(), gameday_to_int(), and wait() or waitq(). You can make what you need out of that. Note, the first two return milliseconds and the last two take seconds.
 

Pazleysox

Member
The functions you need are rollover(), gameday_to_int(), and wait() or waitq(). You can make what you need out of that. Note, the first two return milliseconds and the last two take seconds.

rollover() spits out the same number, regardless of the time of day for me. I tried it over a few minutes. Here's the output I get when I use the rollover() function.

Code:
print(rollover() + " milliseconds to rollover");
print(rollover() / 6000 + " seconds to rollover");
print(rollover() / 60000 + " minutes to rollover");
print(rollover() / 3600000 + " hours to rollover");
print(time_to_string() + " My local time");
Which spits this out:
1549164601 milliseconds to rollover
258194 seconds to rollover
25819 minutes to rollover
430 hours to rollover
12:12:35 EST My local time

I'm sure I can figure out a way to use time_to_string() and the actual time of rollover to do what I need.
 

fronobulax

Developer
Staff member
You probably want to divide milliseconds by 1000 to convert to seconds :)

I'm not sure rollover is working. Maybe I'll get a chance to check.
 

heeheehee

Developer
Staff member
Dumb question: why can't you just use gametime_to_int() by itself?

MinutesToRollover can then be defined as
Code:
int MinutesToRollover() {
  return 1440 - gametime_to_int() / 1000 / 60;
}
(where 1440 is mins in a day)

This should be resilient against DST because rollover happens at the same time UTC each day.

(WaitMinutes() should just be wait(60*num).)
 

fronobulax

Developer
Staff member
So how can that be converted into a readable number?

It is readable to me :)

Being a Unix timestamp (which I had missed before so thanks) it is the number of seconds since Jan 01 1970. (UTC). So you can look for routines which convert it into time format that you can work with. Since you are interested in time to rollover you could also get the current time in Unix format, subtract it from the rollover time and that gives you time until rollover in seconds.

But heeheehee's solution is good too :)
 

Pazleysox

Member
Dumb question: why can't you just use gametime_to_int() by itself?

MinutesToRollover can then be defined as
Code:
int MinutesToRollover() {
  return 1440 - gametime_to_int() / 1000 / 60;
}
(where 1440 is mins in a day)

This should be resilient against DST because rollover happens at the same time UTC each day.

(WaitMinutes() should just be wait(60*num).)

I will have to try this. Thank you. :)
 
Top