Gameday to int: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
This was in r8594, even though it was missing from the changelog.
 
imported>Bale
m markup fix
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{
{{
#vardefine:name|gameday_to_int}}{{
#vardefine:name|gameday_to_int}}{{
#vardefine:return_type|string}}{{
#vardefine:return_type|int}}{{


FunctionPage|
FunctionPage|
Line 13: Line 13:
}}|
}}|


function_description=Returns the current KoL game date using the in game calendar as an integer from 1 to 95 where "Jarlsuary 1" is 1 and "Dougtember 8" is 95.|
function_description=Returns the current KoL game date using the in game calendar as an integer from 0 to 95 where "Jarlsuary 1" is 0 and "Dougtember 8" is 95.|


code1={{CodeSample|
code1={{CodeSample|
Line 38: Line 38:
}}
}}
== Notes ==
== Notes ==
The value returned prints actual game date, so it is influenced by rollover. [[today_to_string]]() is determined by your computer's own clock.
The value returned prints actual game date, so it is influenced by rollover. {{f|today_to_string}} is determined by your computer's own clock.
{{SeeAlso|today_to_string|gameday_to_int}}
{{SeeAlso|today_to_string|gameday_to_string|time_to_string|now_to_string}}
[[Category:Math and Numbers]]
 
[[Category:Miscellaneous Functions]]

Latest revision as of 08:56, 27 April 2011

Function Syntax

int gameday_to_int()

Returns the current KoL game date using the in game calendar as an integer from 0 to 95 where "Jarlsuary 1" is 0 and "Dougtember 8" is 95.

Code Samples

This code will tell you how many game days it has been since you last logged into KoL.

int last = get_property("currentLogin").to_int();
if(last == gameday_to_int())
   print("You've already logged in today.");
else if((last + 1) % 96 == gameday_to_int())
   print("There has been one rollover since your last login.");
else {
   int interval;
   if(gameday_to_int() > last)
      interval = gameday_to_int() - last;
   else
      interval = 95 - last + gameday_to_int();
   print("It has been "+interval +" days since last your login.");
}
set_property("currentLogin", gameday_to_int());

CLI Equivalent

The CLI command "moon" will also print the current game date along with other information.


Notes

The value returned prints actual game date, so it is influenced by rollover. today_to_string() is determined by your computer's own clock.

See Also

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