Miscellaneous Functions: Difference between revisions
imported>Raeith No edit summary |
imported>Raeith "Sample" linkys |
||
Line 7: | Line 7: | ||
<p><strong>boolean cli_execute( string command )</strong><br /> | <p><strong>boolean cli_execute( string command )</strong><br /> | ||
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.<br /> | 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.<br /> | ||
See the [http://kolmafia.sourceforge.net/scripting.html CLI manual] for more details.</p> | See the [http://kolmafia.sourceforge.net/scripting.html CLI manual] for more details.<br /> | ||
<em>Sample</em>:[http://www.wiki.kolmafia.us/index.php/%28ASHRM%29_Code_Samples#Sample_4:_Hedging Hedging]</p> | |||
<p><strong>void wait( int delay )</strong><br /> | <p><strong>void wait( int delay )</strong><br /> | ||
Line 15: | Line 16: | ||
boolean set_property( string key, string value )</strong><br /> | boolean set_property( string key, string value )</strong><br /> | ||
Gets or sets a stored property from your character’s .kcs file.<br /> | Gets or sets a stored property from your character’s .kcs file.<br /> | ||
The KoLmafia [http://www.wiki.kolmafia.us/index.php/%28ASHRM%29_KoLMafia_Properties properties] page contains details on many of the keys that are available for access.</p> | The KoLmafia [http://www.wiki.kolmafia.us/index.php/%28ASHRM%29_KoLMafia_Properties properties] page contains details on many of the keys that are available for access.<br /> | ||
<em>Sample</em>:[http://www.wiki.kolmafia.us/index.php/%28ASHRM%29_Code_Samples#Sample_2:_Battlefield_gather Battlefield_gather]</p> | |||
<p><strong>string boolean_to_string( boolean flag )<br /> | <p><strong>string boolean_to_string( boolean flag )<br /> |
Revision as of 04:48, 9 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
string boolean_to_string( boolean flag )
string int_to_string( int number )
string float_to_string( float number )
string item_to_string( item it )
string zodiac_to_string( zodiac sign )
string location_to_string( location place )
string familiar_to_string( class cl )
string class_to_string( class cl )
string stat_to_string( stat st )
string skill_to_string( skill sk )
string effect_to_string( effect ef )
string element_to_string( element el )
string slot_to_string( slot sl )
string monster_to_string( monster eek )
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.
boolean string_to_boolean( string str )
int string_to_int( string str )
float string_to_float( string str )
item string_to_item( string str )
zodiac string_to_zodiac( string str )
location string_to_location( string str )
familiar string_to_familiar( string str )
class string_to_class( string str )
stat string_to_stat( string str )
skill string_to_skill( string str )
effect string_to_effect( string str )
slot string_to_slot( string str )
element string_to_element( string str )
monster string_to_monster( string str )
Converts strings to ASH variables. Useful for converting the result of a get_property() call intoa legitimate value.
int item_to_int( item it )
int skill_to_int ( skill sk )
int effect_to_int ( effect eff )
int familiar_to_int ( familiar pet )
int slot_to_int ( slot sl )
int element_to_int ( element el )
Converts the ASH-based object into the number that will be recognized by the KoL server. Needed when you’re building raw URLs from time to time.
item int_to_item( int nItem )
skill int_to_skill ( int nSkill )
effect int_to_effect ( int nEffect )
familiar int_to_familiar ( int nFamiliar )
slot int_to_slot ( int nSlot )
element int_to_element ( int nElement )
Converts the KoL-based number into an associated ASH object. These aren’t the commands you’re looking for. You can go about your business.
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