Difference between revisions of "Gametime to int"

From Kolmafia
Jump to navigation Jump to search
imported>Theraze
imported>Theraze
m
 
Line 17: Line 17:
 
code1={{CodeSample|
 
code1={{CodeSample|
 
title=Code Sample 1|
 
title=Code Sample 1|
description=This code will tell you how many MS it took to list the gCLI commands.|
+
description=This code will tell you how many ms it took to list the gCLI commands.|
 
code=<syntaxhighlight>
 
code=<syntaxhighlight>
 
int starttime = gametime_to_int();
 
int starttime = gametime_to_int();
 
CLI_EXECUTE("help");
 
CLI_EXECUTE("help");
print("It took "+(gametime_to_int()-starttime)+" MS to list all gCLI commands.");
+
print("It took "+(gametime_to_int()-starttime)+" ms to list all gCLI commands.");
 
</syntaxhighlight>}}|
 
</syntaxhighlight>}}|
  
 
code2={{CodeSample|
 
code2={{CodeSample|
 
title=Code Sample 2|
 
title=Code Sample 2|
description=This code will tell you how many MS it has been since KoL's official rollover time.|
+
description=This code will tell you how many ms it has been since KoL's official rollover time.|
 
code=<syntaxhighlight>
 
code=<syntaxhighlight>
print("It has been "+gametime_to_int()+" MS since the rollover began.");
+
print("It has been "+gametime_to_int()+" ms since the rollover began.");
 
</syntaxhighlight>}}|
 
</syntaxhighlight>}}|
  

Latest revision as of 16:54, 9 July 2011

Function Syntax

int gametime_to_int()

Returns the current KoL game time using milliseconds since rollover.

Code Sample 1

This code will tell you how many ms it took to list the gCLI commands.

int starttime = gametime_to_int();
CLI_EXECUTE("help");
print("It took "+(gametime_to_int()-starttime)+" ms to list all gCLI commands.");

Code Sample 2

This code will tell you how many ms it has been since KoL's official rollover time.

print("It has been "+gametime_to_int()+" ms since the rollover began.");

Code Sample 3

This code will tell you long since KoL's official rollover time began without hitting the server.

print("It has been "+(gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60)+" since the rollover began.");

Code Sample 4

This code will tell you how long until KoL's next official rollover time.

print("You have "+(23 - (gametime_to_int() / (86400000 / 24)))+":"+(59 - ((gametime_to_int() / (86400000 / 1440)) % 60))+" left until rollover begins.")


See Also

today_to_string() | gameday_to_int() | gameday_to_string() | time_to_string() | now_to_string()