Miscellaneous Functions: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Efilnikufecin
imported>Efilnikufecin
Line 18: Line 18:
The KoLmafia [[%28ASHRM%29_KoLMafia_Properties|properties]] page contains details on many of the keys that are available for access.<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>
<em>Sample</em>:[[%28ASHRM%29_Code_Samples#Sample_2:_Battlefield_gather|Battlefield_gather]]</p>
<p><strong>string boolean_to_string( boolean flag )<br />
string int_to_string( int number )<br />
string float_to_string( float number )<br />
string item_to_string( [[%28ASHRM%29_Dataype_Constants#.24item.5Bconstant.5D|item it]] )<br />
string zodiac_to_string( [[%28ASHRM%29_Dataype_Constants#.24zodiac.5Bconstant.5D|zodiac sign]] )<br />
string location_to_string( [[%28ASHRM%29_Dataype_Constants#.24location.5Bconstant.5D|location place]] )<br />
string familiar_to_string( [[%28ASHRM%29_Dataype_Constants#.24class.5Bconstant.5D|class cl]] )<br />
string class_to_string( [[%28ASHRM%29_Dataype_Constants#.24class.5Bconstant.5D|class cl]] )<br />
string stat_to_string( [[%28ASHRM%29_Dataype_Constants#.24stat.5Bconstant.5D|stat st]] )<br />
string skill_to_string( [[%28ASHRM%29_Dataype_Constants#.24skill.5Bconstant.5D|skill sk]] )<br />
string effect_to_string( [[%28ASHRM%29_Dataype_Constants#.24effect.5Bconstant.5D|effect ef]] )<br />
string element_to_string( element el )<br />
string slot_to_string( [[%28ASHRM%29_Dataype_Constants#.24slot.5Bconstant.5D|slot sl]] )<br />
string monster_to_string( [[%28ASHRM%29_Dataype_Constants#.24monster.5Bconstant.5D|monster eek]] )</strong><br />
Converts in-game variables to printable counterparts. The print command will cast non-string values properly now, but these are still useful for building URLs and setting properties.</p>
<p><strong>boolean string_to_boolean( string str )<br />
int string_to_int( string str )<br />
float string_to_float( string str )<br />
item string_to_item( string str )<br />
zodiac string_to_zodiac( string str )<br />
location string_to_location( string str )<br />
familiar string_to_familiar( string str )<br />
class string_to_class( string str )<br />
stat string_to_stat( string str )<br />
skill string_to_skill( string str )<br />
effect string_to_effect( string str )<br />
slot string_to_slot( string str )<br />
element string_to_element( string str )<br />
monster string_to_monster( string str )</strong><br />
Converts strings to ASH variables.  Useful for converting the result of a get_property() call intoa legitimate value.</p>
<p><strong>int item_to_int( [[%28ASHRM%29_Dataype_Constants#.24item.5Bconstant.5D|item it]] )<br />
int skill_to_int ( [[%28ASHRM%29_Dataype_Constants#.24skill.5Bconstant.5D|skill sk]] )<br />
int effect_to_int ( [[%28ASHRM%29_Dataype_Constants#.24effect.5Bconstant.5D|effect ef]]f )<br />
int familiar_to_int ( [[%28ASHRM%29_Dataype_Constants#.24familiar.5Bconstant.5D|familiar pet]] )<br />
int slot_to_int ( [[%28ASHRM%29_Dataype_Constants#.24slot.5Bconstant.5D|slot sl]] )<br />
int element_to_int ( element el )</strong><br />
Converts the ASH-based object into the number that will be recognized by the KoL server. Needed when you&#8217;re building raw URLs from time to time.</p>
<p><strong>item int_to_item( int nItem )<br />
skill int_to_skill ( int nSkill )<br />
effect int_to_effect ( int nEffect )<br />
familiar int_to_familiar ( int nFamiliar )<br />
slot int_to_slot ( int nSlot )<br />
element int_to_element ( int nElement )</strong><br />
Converts the KoL-based number into an associated ASH object. These aren&#8217;t the commands you&#8217;re looking for. You can go about your business.</p>


<p><strong>void file_to_map( string file_to_load, map map_to_fill )<br />
<p><strong>void file_to_map( string file_to_load, map map_to_fill )<br />

Revision as of 07:26, 15 January 2007

Part 6 - Miscellaneous

Mostly internal stuff. Some good for everyone, some only for ASH wizards.

void print( string helloworld )
Prints the given string to the graphical CLI window and to the status line of the main Adventuring window

boolean cli_execute( string command )
Executes the given command as if it were entered into the graphical CLI window. This can be used for CLI commands or, if you’re careful and not an asshat, for raw URLs.
See the CLI manual for more details.
Sample:Hedging

void wait( int delay )
Does nothing for the desired number of seconds.

string get_property( string key )
boolean set_property( string key, string value )

Gets or sets a stored property from your character’s .kcs file.
The KoLmafia properties page contains details on many of the keys that are available for access.
Sample:Battlefield_gather

void file_to_map( string file_to_load, map map_to_fill )
void map_to_file( map map_to_save, string file_to_write )

Loads and saves maps as tab-delimited text files.

int random( int range )
Generates a random integer between 0 and (range-1) inclusive.

int round( float ratio )
int floor( float ratio )
int ceil( float ratio )
int truncate( float ratio )

Returns an integer near the given real number. Respectively, it returns the nearest, next lowest, next highest, and decimal-stripped integer.

int count( map )
Returns the number of defined keys for the aggregate.

void clear( map )
Remove all keys from a map.

void disable( string function_name )
void enable( string function_name )

For debugging purposes disables or enables the indicated function

float square_root( float value )
returns the square root of the passed value

string today_to_string()
Returns today’s (real-world) date in the form yyyymmdd. It is based on your computer’s system date