Miscellaneous Functions: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
No edit summary
Add "gCLI Command Functions" section
 
(195 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
== Part 1 - Your Character ==
{{TOCright}}
== Chat Functions ==
{{Flink|void|chat_clan|string}}
{{Flink|void|chat_clan|string|string|desc=Sends a message to clan chat.}}
{{Flink|void|chat_macro|string|desc=Submits a chat macro to KoL.}}
{{Flink|void|chat_notify|string|string|desc=Sends a notification to the player's own chat.}}
{{Flink|void|chat_private|string|string|desc=Sends a private message to another player.}}
{{Flink|boolean|is_online|string|desc=Check to see if a player is online.}}
{{Flink|boolean [string]|who_clan|desc=Returns a list of whom is in your clan and if they are in chat.}}
{{Flink|boolean|can_faxbot|monster|desc=Check to see if a monster can be faxed.}}
{{Flink|boolean|faxbot|monster|desc=Attempts to receive a fax of a given monster.}}


=== '''The Basics''' ===
== Debugging Functions ==  
<hr>
{{Flink|void|disable|string|desc=Disables the specified function.}}
<p><em>We&#8217;ll start with a long look in the mirror.  Here&#8217;s how to tell about you.</em></p>
{{Flink|void|enable|string|desc=Enables the specified function.}}
{{Flink|buffer|load_html|string|desc=Works like visit_url(), but for debugging.}}
{{Flink|string|make_url|string|boolean|boolean|desc=Crafts the URL to visit.}}


<p><strong>string [[my_name()]]</strong><br />
== File Input/Output Functions ==
Returns your character&#8217;s name.</p>
{{FunctionEmbed|buffer_to_file|format=signature|desc=yes}}
{{FunctionEmbed|file_to_array|format=signature|desc=yes}}
{{FunctionEmbed|file_to_buffer|format=signature|desc=yes}}
{{Flink|boolean|file_to_map|string|aggregate|desc=Loads a map from a tab-delimited text file.}}
{{Flink|boolean|map_to_file|aggregate|string|desc=Saves a map to a tab-delimited text file.}}


<p><strong>class [[my_class()]]</strong><br />
== gCLI Command Functions ==
Returns your class.<br />
{{FunctionEmbed|cli_execute|format=signature|desc=yes}}
<em>Sample</em>: [[%28ASHRM%29_Code_Samples#Sample_1:_Seltzer|Seltzer]]</p>
{{FunctionEmbed|cli_execute_output|format=signature|desc=yes}}


<p><strong>int [[my_level()]]</strong><br />
== Map Management Functions ==
Returns your level<br />
''Note: Information about maps (including creating, assigning, and removing keys, can be found at [[Data Structures#Maps|Map Data Structures]].''
<em>Sample</em>: [[%28ASHRM%29_Code_Samples#Sample_2:_Battlefield_gather|Battlefield_gather]]</p>


<p><strong>int [[my_adventures()]]</strong><br />
{{Flink|int|count|aggregate|desc=Returns the number of defined keys for the specified aggregate.}}
Returns the number of adventures that you have remaining today.<br />
{{Flink|void|clear|aggregate|desc=Removes all keys from the specified aggregate.}}
Sample:[[%28ASHRM%29_Code_Samples#Sample_4:_Hedging|Hedging]]</p>


<p><strong>int [[my_turncount()]]</strong><br />
== Time Functions ==
Returns the number of adventures you have had in this ascension.</p>
{{Flink|string|format_date_time|string|string|string|desc=Reformats dates.}}
{{Flink|int|gameday_to_int|desc=Returns the current KoL date as an integer.}}
{{Flink|string|gameday_to_string|desc=Returns the current KoL date as a string.}}
{{Flink|int|gametime_to_int|desc=Returns the current KoL time in ms as an integer.}}
{{Flink|string|now_to_string|string|desc=Returns current local time/date in SimpleDateFormat format.}}
{{Flink|string|time_to_string|desc=Returns the current local time in HH:mm:ss z format.}}
{{Flink|string|today_to_string|desc=Returns the current local day in ISO format.}}


<p><strong>int [[my_inebriety()]]<br />
== SVN Functions ==
int [[inebriety_limit()]]</strong><br />
''There is much additional information in the [[SVN Primer]]''.
Returns how drunk you are and the limit at which you must stop adventuring</p>
{{Flink|boolean|svn_exists|string|desc=Returns true if a valid working copy named projectname exists in the svn/ folder.}}
{{Flink|boolean|svn_at_head|string|desc=Returns true if projectname exists, is a valid working copy, and is currently at the same revision number as the repository.}}
{{Flink|record|svn_info|string|desc=Returns a record containing additional information about the given projectname: svnurl, last author, last revision, last change date.}}


<p><strong>boolean [[can_eat()]]<br />
== User Interaction ==
boolean [[can_drink()]]<br />
{{Flink|void|print|string|{{opt|string}}|desc=Prints to CLI and status line of Adventuring window, optionally in a specified color.}}
boolean [[can_interact()]]<br />
{{Flink|void|print_html|string|desc=Prints to CLI, parsing any included html.}}
boolean [[in_hardcore()]]</strong><br />
{{Flink|void|logprint|string|desc=Prints to the session log.}}
Tells you about your limitations due to ronin, hardcore, or voluntary dietary restrictions</p>
{{Flink|void|wait|int}}
{{Flink|void|waitq|int|desc=Sleeps for the specified number of seconds.}}
{{Flink|boolean|user_confirm|string|desc=Allows user input in Y/N format.}}


== Property Functions ==
{{Flink|boolean [string]|get_all_properties|string|boolean|desc=Returns a map of all user or global properties.}}
{{FunctionEmbed|property_exists|format=signature|desc=yes}}
{{FunctionEmbed|property_has_default|format=signature|desc=yes}}
{{FunctionEmbed|property_default_value|format=signature|desc=yes}}
{{Flink|string|get_property|string}}
{{Flink|string|get_property|string|boolean|desc=Gets a global or user preference as appropriate.}}
{{Flink|void|set_property|string|string|desc=Sets a global or user preference as appropriate.}}
{{FunctionEmbed|remove_property|format=signature|desc=yes}}
{{FunctionEmbed|rename_property|format=signature|desc=yes}}


== Other Functions ==
{{FunctionEmbed|abort|format=signature|desc=yes}}
{{FunctionEmbed|all_monsters_with_id|format=signature|desc=yes}}
{{Flink|void|batch_open|desc=Used to mark the beginning of a block of functions to operate in batch mode (see page for {{f|batch_close}} for details).}}
{{Flink|boolean|batch_close|desc=Used to mark the end of a block of functions to operate in batch mode (see page for details).}}
{{Flink|int|get_revision|desc=Returns the current KoLmafia revision number.}}
{{Flink|string|get_version|desc=Returns the most recent KoLmafia version.}}
{{Flink|string|get_player_id|string|desc=Returns the user id number of a given player.}}
{{FunctionEmbed|is_dark_mode|format=signature|desc=yes}}
{{Flink|string|to_json|aggregate|desc=Converts a simple aggregate into JSON.}}


=== '''Your Familiar''' ===
Additional functions that are considered not really to be ash functions are available in [[Miscellaneous ASH Features#Special Syntax Functions|Misc ASH Features]]
<hr>
A bit of information about your pet can be helpfull too.


<p><strong>familiar [[my_familiar()]]</strong><br />
[[Category:Scripting]]
Returns the familiar you are carrying now</p>
 
<p><strong>int familiar_weight( [[%28ASHRM%29_Datatype_Constants#.24familiar.5Bconstant.5D|familiar pet]] )<br />
int [[familiar_weight_adjustment()]]</strong><br />
Returns the raw weight of the specified familiar, and the difference between the raw and currently buffed weight of your equipped familiar.</p>
 
=== '''Basic Stats''' ===
<hr>
 
<p><strong>stat [[my_primestat()]]</strong><br />
Returns the stat associated with your class.<br />
Sample:[[%28ASHRM%29_Code_Samples#Sample_1:_Seltzer|Seltzer]]</p>
 
<p><strong>boolean [[in_moxie_sign()]]<br />
boolean [[in_muscle_sign()]]<br />
boolean [[in_mysticality_sign()]]</strong><br />
Returns your ascension sign and whether it is associated with a specific stat zone.</p>
 
<p><strong>int [[my_hp()]]<br />
int [[my_mp()]]<br />
int [[my_maxhp()]]<br />
int [[my_maxmp()]]</strong><br />
Returns your current and highest available HP and MP levels<br />
Sample:[[%28ASHRM%29_Code_Samples#Sample_3:_Skill_upkeep|Skill_upkeep]]</p>
 
<p><strong>int my_basestat( [[%28ASHRM%29_Datatype_Constants#.24stat.5Bconstant.5D|stat st]] )<br />
int my_buffedstat( [[%28ASHRM%29_Datatype_Constants#.24stat.5Bconstant.5D|stat st]] )</strong><br />
Returns your base and buffed values in the given stat</p>
 
<p><strong>int [[current_mind_control_level()]]<br />
boolean mind_control (int level)</strong><br />
Returns or sets the level of the Super-Secret Canadian Mind-Control Device</p>
 
<p><strong>[[%28ASHRM%29_Datatype_Constants#.24stat.5Bconstant.5D|stat]] [[stat_bonus_today()]]<br />
[[%28ASHRM%29_Datatype_Constants#.24stat.5Bconstant.5D|stat]] [[stat_bonus_tomorrow()]]</strong><br />
Returns the stat that is benefitted by the moon phases today or tomorrow.  If it is an &#8220;ordinary&#8221; day, the return value is $stat[none].</p>
 
 
 
=== '''More Advanced Stats''' ===
<hr>
 
<p><strong>stat [[current_hit_stat()]]<br />
int [[buffed_hit_stat()]]</strong><br />
Returns the stat that is currently used to calculate hit percentages and the buffed value of that stat.</p>
 
<p><strong>int [[raw_damage_absorption()]]<br />
float [[damage_absorption_percent()]]<br />
int [[damage_reduction()]]</strong><br />
Returns the total DA of all of your gear and effects, the percentage of damage that is blocked by it, and the further damage that is deducted because of DR effects.</p>
 
<p><strong>float elemental_resistance( element elem )<br />
float cold_resistance()<br />
float hot_resistance()<br />
float sleaze_resistance()<br />
float spooky_resistance()<br />
float stench_resistance()</strong><br />
Returns the percentage of damage reduction from the indicated elemental damage.</p>
 
<p><strong>int [[combat_rate_modifier()]]<br />
int [[initiative_modifier()]]<br />
int [[fixed_experience_bonus()]]<br />
int [[meat_drop_modifier()]]<br />
int [[item_drop_modifier()]]</strong><br />
Returns the adjustments to your percentage of combat adventures, your chances of winning inititative in battle, the amount of bonus experience you receive, and the amount of meat and percentage of item drops from successful combat.</p>
 
<p><strong>int [[monster_level_adjustment()]]</strong><br />
Returns your degree to which you have effected the monster level (including the MCD).</p>

Latest revision as of 14:55, 23 December 2020

Chat Functions

void chat_clan( string )

void chat_clan( string, string )

Sends a message to clan chat.

void chat_macro( string )

Submits a chat macro to KoL.

void chat_notify( string, string )

Sends a notification to the player's own chat.

void chat_private( string, string )

Sends a private message to another player.

boolean is_online( string )

Check to see if a player is online.

boolean [string] who_clan()

Returns a list of whom is in your clan and if they are in chat.

boolean can_faxbot( monster )

Check to see if a monster can be faxed.

boolean faxbot( monster )

Attempts to receive a fax of a given monster.


Debugging Functions

void disable( string )

Disables the specified function.

void enable( string )

Enables the specified function.

buffer load_html( string )

Works like visit_url(), but for debugging.

string make_url( string, boolean, boolean )

Crafts the URL to visit.


File Input/Output Functions

boolean buffer_to_filebuffer, string )

Saves a buffer to a text file. Returns true on success, false on failure.

string [int] file_to_arraystring )

Reads data from a text file and returns a map of strings containing each line.

buffer file_to_bufferstring )

Loads the entire contents of a text file into a buffer.

boolean file_to_map( string, aggregate )

Loads a map from a tab-delimited text file.

boolean map_to_file( aggregate, string )

Saves a map to a tab-delimited text file.


gCLI Command Functions

boolean cli_executestring )

Executes a string as a gCLI command. Returns true on success, false on failure.

string cli_execute_outputstring )

Executes a gCLI command, capturing and returning the gCLI output.

Map Management Functions

Note: Information about maps (including creating, assigning, and removing keys, can be found at Map Data Structures.

int count( aggregate )

Returns the number of defined keys for the specified aggregate.

void clear( aggregate )

Removes all keys from the specified aggregate.


Time Functions

string format_date_time( string, string, string )

Reformats dates.

int gameday_to_int()

Returns the current KoL date as an integer.

string gameday_to_string()

Returns the current KoL date as a string.

int gametime_to_int()

Returns the current KoL time in ms as an integer.

string now_to_string( string )

Returns current local time/date in SimpleDateFormat format.

string time_to_string()

Returns the current local time in HH:mm:ss z format.

string today_to_string()

Returns the current local day in ISO format.


SVN Functions

There is much additional information in the SVN Primer.

boolean svn_exists( string )

Returns true if a valid working copy named projectname exists in the svn/ folder.

boolean svn_at_head( string )

Returns true if projectname exists, is a valid working copy, and is currently at the same revision number as the repository.

record svn_info( string )

Returns a record containing additional information about the given projectname: svnurl, last author, last revision, last change date.


User Interaction

void print( string, [string] )

Prints to CLI and status line of Adventuring window, optionally in a specified color.

void print_html( string )

Prints to CLI, parsing any included html.

void logprint( string )

Prints to the session log.

void wait( int )

void waitq( int )

Sleeps for the specified number of seconds.

boolean user_confirm( string )

Allows user input in Y/N format.


Property Functions

boolean [string] get_all_properties( string, boolean )

Returns a map of all user or global properties.

boolean property_existsstring, boolean? )

Checks whether a property exists.

boolean property_has_defaultstring )

Checks if a property has a built-in default value.

string property_default_valuestring )

Returns the default value of a property, or an empty string if a default value does not exist.

string get_property( string )

string get_property( string, boolean )

Gets a global or user preference as appropriate.

void set_property( string, string )

Sets a global or user preference as appropriate.

string remove_propertystring, boolean? )

Removes or resets a property and returns its previous value.

boolean rename_propertystring, string )

Renames a property. Returns true on success, false on failure.

Other Functions

void abortstring? )

Immediately halts the current script and all queued functions.

boolean [monster] all_monsters_with_id()

Returns a map of all monsters that have a non-zero monster ID.

void batch_open()

Used to mark the beginning of a block of functions to operate in batch mode (see page for batch_close() for details).

boolean batch_close()

Used to mark the end of a block of functions to operate in batch mode (see page for details).

int get_revision()

Returns the current KoLmafia revision number.

string get_version()

Returns the most recent KoLmafia version.

string get_player_id( string )

Returns the user id number of a given player.

boolean is_dark_mode()

Checks if the current KoLmafia theme is dark mode.

string to_json( aggregate )

Converts a simple aggregate into JSON.


Additional functions that are considered not really to be ash functions are available in Misc ASH Features