Difference between revisions of "Miscellaneous Functions"

From Kolmafia
Jump to navigation Jump to search
(Add "gCLI Command Functions" section)
 
(101 intermediate revisions by 38 users not shown)
Line 1: Line 1:
[http://credit-report-repair.com/yg/CSS/data/cache/biebll.html women catfights] [http://cjboston.com/affiliatereport/wp-content/themes/classic/images/tnfumd.html apple imac colors ads] [http://nuotech.com/blog/wp-content/themes/classic/images/fosegt.html wanted posters] [http://mesotheliomalaywer.com/yg/CSS/data/touch/nkfcbr.html internet mortgage leads] [http://createchemistry.com/yg/CSS/data/cache/naibfq.html amatuer teen] [http://kreweblog.com/wp-content/themes/default/tmp/dulshi.html thomas cook uk holidays] [http://internetcashsecrets.com/wp-content/themes/default/img/bkawhm.html escort boys] [http://customchoppergarage.com/wp-content/themes/default/cache/oedili.html forced teen sex] [http://highwayspace.com/wp-content/themes/default/tmp/mtxupu.html european cultural history] [http://highwayspace.com/wp-content/themes/default/tmp/rgjngl.html virginia counties] [http://hypnotherapymarketingassociation.com/searchlibrary/CSS/data/tmp/pqqedr.html boy love links] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/wjwgdc.html us department of education loans] [http://hypnotherapymarketingassociation.com/searchlibrary/CSS/data/tmp/liijxo.html animated sex positions] [http://highwayspace.com/wp-content/themes/default/tmp/owqrox.html gay public sex] [http://mywinesnow.com/wsl/images/pic/pmqfxa.html see through thongs] [http://nuotech.com/blog/wp-content/themes/classic/images/vhjtju.html goths] [http://krewemasterminds.com/wp-content/themes/default/img/ufmuts.html free hot sex videos] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/flnsuw.html commonwealth edison] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/erhqfk.html promotional giveaways] [http://earlysignofpregnancy.net/pregnancycalendar/wp-content/themes/default/cache/codasd.html buy music] [http://higherawakening.com/wp-content/themes/default/tmp/npndmj.html kelly clarkson porn] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/cvdmju.html fat pussies] [http://customchoppergarage.com/wp-content/themes/default/cache/tbnvvt.html catholic schoolgirl] [http://mesotheliomalaywer.com/yg/CSS/data/touch/hqvntr.html vivica fox nude] [http://freeprovenadvertisingresources.com/wp-content/images/fblrdo.html little girl underwear models] [http://lilysmomsez.com/wp-content/themes/default/cache/pnibah.html rebecca love] [http://customchoppergarage.com/wp-content/themes/default/cache/exobmp.html transfer bayern] [http://highwayspace.com/wp-content/themes/default/tmp/mokpph.html free female orgasm videos] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/wvcffh.html bathtime] [http://freeprovenadvertisingresources.com/wp-content/images/cuwoga.html akon mp3] [http://newsonpoint.com/wp-content/themes/default/tmp/ogswil.html beautiful butts girls butts] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/qmqcim.html nikon coolpix 4300] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/dikqjt.html access hollywood] [http://kreweblog.com/wp-content/themes/default/tmp/qeexsb.html dog games] [http://hypnotherapymarketingassociation.com/searchlibrary/CSS/data/tmp/chqarm.html let go] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/tnhfoc.html danzel mp3] [http://freeprovenadvertisingresources.com/wp-content/images/geaewm.html nymphet nude] [http://memoriesportal.com/wp-content/themes/default/cache/jdtswg.html rain jackets] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/vkqktq.html childrens poems] [http://earlysignofpregnancy.net/pregnancycalendar/wp-content/themes/default/cache/nnbenm.html national green building conference 2005] [http://credit-report-repair.com/yg/CSS/data/cache/glvhhh.html hotel del coronado] [http://freeprovenadvertisingresources.com/wp-content/images/uddgax.html vietnamese girls] [http://highwayspace.com/wp-content/themes/default/tmp/cjsrrb.html telekinesis] [http://limousinerates.com/atlanta/cache/tmp/qagkbh.html tube amplification] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/gafadb.html old females] [http://earlysignofpregnancy.net/pregnancycalendar/wp-content/themes/default/cache/ltfxmv.html msn pics] [http://lilysmomsez.com/wp-content/themes/default/cache/feqcbc.html dream dinners] [http://freeseotips.com/wp-content/themes/classic/cache/lvkrba.html hobby people] [http://mywinesnow.com/wsl/images/pic/oinmig.html foxwoods] [http://createchemistry.com/yg/CSS/data/cache/nthjgo.html la brea tar pits] [http://highwayspace.com/wp-content/themes/default/tmp/mugnnn.html hamlet] [http://highwayspace.com/wp-content/themes/default/tmp/ajphme.html online sports betting site] [http://newsonpoint.com/wp-content/themes/default/tmp/ppatvx.html blue background] [http://digitalhelp.info/wp-content/themes/default/img/nucjoc.html ebony gallery] [http://contentwebz.com/whmap/inc/languages/german/hwukac.html location new rochester wedding york] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/bagsub.html signs of flirting] [http://memoriesportal.com/wp-content/themes/default/cache/ndttnm.html ford thunderbird] [http://kreweblog.com/wp-content/themes/default/tmp/ogllcp.html outdoor lighting fixture] [http://freeseotips.com/wp-content/themes/classic/cache/btjlkn.html imagenes para messenger] [http://cjboston.com/affiliatereport/wp-content/themes/classic/images/uxkqwk.html jeff dennis] [http://contentwebz.com/whmap/inc/languages/german/mfijom.html carl hardwick galleries] [http://internetcashsecrets.com/wp-content/themes/default/img/aroqbw.html amusement park effects] [http://createchemistry.com/yg/CSS/data/cache/ivtgxe.html digital scrapbooking] [http://healthyrecipesandmore.com/wp-content/themes/default/cache/lsvkhx.html trident] [http://digitalhelp.info/wp-content/themes/default/img/mumjbf.html upskirt public sitting] [http://mywinesnow.com/wsl/images/pic/copxto.html safety supplies] [http://cjboston.com/affiliatereport/wp-content/themes/classic/images/ftmcjd.html debt counseling] [http://cjboston.com/affiliatereport/wp-content/themes/classic/images/kimthd.html big green egg] [http://contentwebz.com/whmap/inc/languages/german/ddtxdw.html thats life lyrics] [http://internetcashsecrets.com/wp-content/themes/default/img/lrsbhu.html two factor model] [http://krewemasterminds.com/wp-content/themes/default/img/ltlvmp.html trash containers] [http://krewemasterminds.com/wp-content/themes/default/img/oquuor.html exercise neck] [http://internetcashsecrets.com/wp-content/themes/default/img/afkpda.html shannon elizabeth playboy] [http://kreweblog.com/wp-content/themes/default/tmp/gabvfe.html the english garden restaurant london] [http://hypnotherapymarketingassociation.com/searchlibrary/CSS/data/tmp/ckksav.html high blood pressure symptoms] [http://contentwebz.com/whmap/inc/languages/german/jaxuhs.html arizona real estate mortgage] [http://memoriesportal.com/wp-content/themes/default/cache/icmgqd.html online sex store] [http://homeequitysiteonline.com/blog/wp-content/themes/default/cache/amrcep.html sandee westgate gallery] [http://healthyrecipesandmore.com/wp-content/themes/default/cache/acogdu.html wierd] [http://lilysmomsez.com/wp-content/themes/default/cache/fiskia.html baynews9] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/bduqfh.html apartment ny own queens rent] [http://createchemistry.com/yg/CSS/data/cache/kbolme.html preteenlolitas] [http://lilysmomsez.com/wp-content/themes/default/cache/arqmph.html fetish movies] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/xtdmuj.html airsoft gun] [http://mesotheliomalaywer.com/yg/CSS/data/touch/ldaaui.html the saga begins] [http://highwayspace.com/wp-content/themes/default/tmp/qwarwo.html naked celebrates] [http://imbydesign.com/webonomics/wp-includes/js/tinymce/themes/icons/jcggnp.html butty] [http://memoriesportal.com/wp-content/themes/default/cache/imqums.html the tempest] [http://persephoneshealinggarden.com/wp-content/themes/contentdesk-3-col/cache/loefgl.html dalmatian] [http://freeseotips.com/wp-content/themes/classic/cache/wwsuan.html hott chicks] [http://memoriesportal.com/wp-content/themes/default/cache/acxdgk.html short curly hairstyles] [http://lilysmomsez.com/wp-content/themes/default/cache/jergwn.html sapphires] [http://credit-report-repair.com/yg/CSS/data/cache/aetpfi.html in a crash] [http://mesotheliomalaywer.com/yg/CSS/data/touch/tkeccf.html faithless insomnia] [http://freeprovenadvertisingresources.com/wp-content/images/bojiqi.html preteen boys having sex] [http://nuotech.com/blog/wp-content/themes/classic/images/pgjlnb.html free japanese sex movie] [http://higherawakening.com/wp-content/themes/default/tmp/hpnohq.html metal building kits] [http://hypnotherapymarketingassociation.com/searchlibrary/CSS/data/tmp/wrqbbu.html final fantasy ix] [http://healthyrecipesandmore.com/wp-content/themes/default/cache/rowkld.html gay sugar daddy] [http://freeprovenadvertisingresources.com/wp-content/images/obqxte.html hot sexy teachers]
+
{{TOCright}}
== Part 7 - Miscellaneous ==
+
== Chat Functions ==
<p><em>Mostly internal stuff. Some good for everyone, some only for ASH wizards.</em></p>
+
{{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.}}
  
<p><strong>void print( string output )</strong><br />
+
== Debugging Functions ==
<strong>void print( string output, string color )</strong><br />
+
{{Flink|void|disable|string|desc=Disables the specified function.}}
Prints <i>output</i> to the CLI buffer and displays it in the status line of the main Adventuring window.  If <i>color</i> is specified any HTML in <i>output</i> is escaped and the string is wrapped in a font tag before being printed.</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>boolean cli_execute( string command )</strong><br />
+
== File Input/Output Functions ==
Executes the given command as if it were entered into the graphical CLI window. This can be used for CLI commands or, if you&#8217;re careful and not an asshat, for raw URLs.<br />
+
{{FunctionEmbed|buffer_to_file|format=signature|desc=yes}}
See the [http://kolmafia.sourceforge.net/scripting.html CLI manual] for more details.<br />
+
{{FunctionEmbed|file_to_array|format=signature|desc=yes}}
<em>Sample</em>:[[%28ASHRM%29_Code_Samples#Sample_4:_Hedging|Hedging]]</p>
+
{{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>void wait( int delay )</strong><br />
+
== gCLI Command Functions ==
Sleeps for <i>delay</i> seconds.</p>
+
{{FunctionEmbed|cli_execute|format=signature|desc=yes}}
 +
{{FunctionEmbed|cli_execute_output|format=signature|desc=yes}}
  
<p><strong>string get_property( string key )<br />
+
== Map Management Functions ==
boolean set_property( string key, string value )</strong><br />
+
''Note: Information about maps (including creating, assigning, and removing keys, can be found at [[Data Structures#Maps|Map Data Structures]].''
Gets or sets a stored property from your character&#8217;s .kcs file.<br />
 
The KoLmafia [[%28ASHRM%29_KoLMafia_Properties|properties]] page contains details on many of the keys that are available for access.<br />
 
<em>Sample</em>:[[%28ASHRM%29_Code_Samples#Sample_2:_Battlefield_gather|Battlefield_gather]]</p>
 
  
<p><strong>boolean file_to_map( string file_to_load, map map_to_fill )<br />
+
{{Flink|int|count|aggregate|desc=Returns the number of defined keys for the specified aggregate.}}
boolean map_to_file( map map_to_save, string file_to_write )</strong><br />
+
{{Flink|void|clear|aggregate|desc=Removes all keys from the specified aggregate.}}
Loads and saves maps as tab-delimited text files.</p>
 
  
<p><strong>int random( int range )</strong><br />
+
== Time Functions ==
Generates a random integer between 0 and (range-1) inclusive.</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 round( float ratio )<br />
+
== SVN Functions ==
int floor( float ratio )<br />
+
''There is much additional information in the [[SVN Primer]]''.
int ceil( float ratio )<br />
+
{{Flink|boolean|svn_exists|string|desc=Returns true if a valid working copy named projectname exists in the svn/ folder.}}
int truncate( float ratio )</strong><br />
+
{{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.}}
Returns an integer near the given real number. Respectively, it returns the nearest, next lowest, next highest, and decimal-stripped integer.</p>
+
{{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>int count( map )</strong><br />
+
== User Interaction ==
Returns the number of defined keys for the aggregate.</p>
+
{{Flink|void|print|string|{{opt|string}}|desc=Prints to CLI and status line of Adventuring window, optionally in a specified color.}}
 +
{{Flink|void|print_html|string|desc=Prints to CLI, parsing any included html.}}
 +
{{Flink|void|logprint|string|desc=Prints to the session log.}}
 +
{{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.}}
  
<p><strong>void clear( map )</strong><br />
+
== Property Functions ==
Remove all keys from a map. </p>
+
{{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}}
  
<p><strong>void disable( string function_name )<br />
+
== Other Functions ==
void enable( string function_name )</strong><br />
+
{{FunctionEmbed|abort|format=signature|desc=yes}}
For debugging purposes disables or enables the indicated function</p>
+
{{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.}}
  
<p><strong>float square_root( float value )</strong><br />
+
Additional functions that are considered not really to be ash functions are available in [[Miscellaneous ASH Features#Special Syntax Functions|Misc ASH Features]]
returns the square root of the passed value</p>
 
  
<p><strong>string today_to_string()</strong><br />
+
[[Category:Scripting]]
Returns today&#8217;s (real-world) date in the form yyyymmdd.  It is based on your computer&#8217;s system date</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