Gametime to int: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Theraze
Created page with "{{ #vardefine:name|gametime_to_int}}{{ #vardefine:return_type|int}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate}}| ..."
 
imported>Theraze
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:


code1={{CodeSample|
code1={{CodeSample|
title=Code Samples|
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=
code=<syntaxhighlight>
<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 Samples|
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=
code=<syntaxhighlight>
<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>}}|
}}


code3={{CodeSample|
code3={{CodeSample|
title=Code Samples|
title=Code Sample 3|
description=This code will tell you long since KoL's official rollover time began without hitting the server.|
description=This code will tell you long since KoL's official rollover time began without hitting the server.|
code=
code=<syntaxhighlight>
<syntaxhighlight>
print("It has been "+(gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60)+" since the rollover began.");
print((gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60))
17:34print("It has been "+(gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60)+" since the rollover began.");
</syntaxhighlight>}}|
</syntaxhighlight>}}|
}}


code4={{CodeSample|
code4={{CodeSample|
title=Code Samples|
title=Code Sample 4|
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 long until KoL's next official rollover time.|
code=
code=<syntaxhighlight>
<syntaxhighlight>
print("You have "+(23 - (gametime_to_int() / (86400000 / 24)))+":"+(59 - ((gametime_to_int() / (86400000 / 1440)) % 60))+" left until rollover begins.")
print("You have "+(23 - (gametime_to_int() / (86400000 / 24)))+":"+(59 - ((gametime_to_int() / (86400000 / 1440)) % 60))+" left until rollover begins.")
</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()