Request: get_time() function

Artscrafter

New member
In addition to retrieving the current day from the system clock, it would be nice to have a function that could retrieve the current time of day. I realize that this is fairly limited use, but it could be handy in a few cases. For example, I'm writing a buffbot script and I'm trying to come up with a way that, for example, five minutes before rollover, it stops running itself as a buffbot and equips a rollover adventures outfit.

Any chance of implementing some kind of get_time() method?
 

Aprocalypse

New member
For example, I'm writing a buffbot script and I'm trying to come up with a way that, for example, five minutes before rollover, it stops running itself as a buffbot and equips a rollover adventures outfit.

I currently get another KoLMafia (automated with windows) batch file to run 5 minutes before rollover, changing outfit.

I'd really love this, because I could actually make a buffbot script that never has to be stopped running. This would make me incredibly happy.
 
I'll jump in and voice a suggestion

Code:
//internal kolmafia declarations written in ash format:
record time_type
{
int hour;
int min;
int sec;
}

time_type local_time();
//returns the current time based on the computers clock.
time_type kol_time();
//returns the current kol time based on the systems clock, and time zone settings conversion.

access would be:
Code:
time_type currenttime;
currenttime = local_time();
int currenthour = local_time().hour;
int currentmin = local_time().min;
int currentsec = local_time().sec;

That would give 2 methods of access. I would use 24 hour format.

Also
timetype string_to_time(string input);
would allow those who are playing directly with html to pass a substring from the html to a variable of timetype easily. It would also help in loading string time values from the settings file. string_to_time would accept both 24 hour formatted strings, and 12 hour formatted strings, but return the 24 hour time_type.
 

holatuwol

Developer
While I can see the sensibility of having a time object in its entirety, is there a specific way this will be used, or is the entire time object needed most of the time?
 
Code:
time_type lastcheck;

void looped_raffle();
{
while(local_time().hour != 22 && local_time().min != 15)
 {
 if(local_time().hour == lastcheck.hour +1 && local_time().minute >= lastcheck.minute)
  {
  buy(1, $item[raffle ticket]);
  lastcheck = local_time();
  }
 cli_execute("wait 300");
 visit_url("main.php");
 }
cli_execute("exit");
}

I hear that logging on every hour would be harder on kol's servers than to remain logged on all day.

OK that's how it would be used. This way would be easier for those who are not programmer types to work with.

another option would be:

Code:
{
float now;
now = local_time();
}
where
0 = 12/30/1899 12:00 am
2.75 = 1/1/1900 6:00 pm
-1.25 = 12/29/1899 6:00 am
35065 = 1/1/1996 12:00 am

Similar to the way windows handles time, and have a set of functions wrote up for handling times. That gives access to the date too which I believe is still not desired. This method would be easier for experienced programmers to adapt to.
 

holatuwol

Developer
Well, there's today_to_string(). Realistically, if the only thing people care about are hour and minute, and second really isn't that useful, I could just add two very simple functions. If what people actually care about is the number of minutes that have elapsed since rollover, that would be more sensible to add. Basically, people will ultimately write wrapper utilities anyway, and this is one instance where I don't need to create a complex data structure to give wrapper functions instead of normal functions.
 

BDrag0n

Member
Personally, I'm interested in time from and time to rollover - the first to try and avoid running scripted adventures for the first couple of hours after rollover (to let those players who play straight after rollover do their stuff without any extra lag at a busy time) and the second to ensure the clan buffbot puts on it's jammies just before rollover.

With the recent change to rollover I've lost track of when exactly those things are - rollover is sometime about 4:30 am here, I believe.

On a related note, do scripts function when logged out? I was trying to write a script to check if visit_url contained particular text (in this case "hedge maze") to confirm that KoL was up, with a 40 minute wait if not (followed by a looped series of 5 minute waits in case of long rollover) to try and make sure that the bot logged in soon after rollover for my clannies who play then - but in the morning I just see "Nightly maintenance. Script abort!".

Is there a more elegant method? I was previously using timed .bat file in Windows to log in, but the variable rollover time has thrown that off somewhat.
 
Top