Datatype Conversions: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Efilnikufecin
No edit summary
 
imported>Efilnikufecin
New conversion methods
Line 3: Line 3:
These functions will convert 1 type of data to another.
These functions will convert 1 type of data to another.


<p><strong>string boolean_to_string( boolean flag )<br />
<p><strong>string to_string( variable )</strong><br />
string int_to_string( int number )<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.<br />
string float_to_string( float number )<br />
accepts: boolean, int, float, item, zodiac, location, familiar, class, stat, skill, effect, slot, element, monster</p>
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 />
<p><strong>int to_int( variable )</strong><br />
int string_to_int( string str )<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.<br />
float string_to_float( string str )<br />
accepts: String, float, item, zodiac, location, familiar, skill, effect, slot, element, monster<br />
item string_to_item( string str )<br />
may accept: boolean, class, stat</p>
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 />
<p><strong>boolean to_boolean( variable )</strong><br />
int skill_to_int ( [[%28ASHRM%29_Dataype_Constants#.24skill.5Bconstant.5D|skill sk]] )<br />
Converts the ASH-based object into boolean.<br />
int effect_to_int ( [[%28ASHRM%29_Dataype_Constants#.24effect.5Bconstant.5D|effect ef]]f )<br />
Accepts: String<br />
int familiar_to_int ( [[%28ASHRM%29_Dataype_Constants#.24familiar.5Bconstant.5D|familiar pet]] )<br />
may accept: Int</p>
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 />
<p><strong>float to_float( variable )</strong><br />
skill int_to_skill ( int nSkill )<br />
Converts the ASH-based object into a float.<br />
effect int_to_effect ( int nEffect )<br />
Accepts: String<br />
familiar int_to_familiar ( int nFamiliar )<br />
may accept: int</p>
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>effect skill_to_effect( [[%28ASHRM%29_Dataype_Constants#.24skill.5Bconstant.5D|skill sk]] )<br />
<p><strong>item to_item( variable )</strong><br />
skill effect_to_skill( [[%28ASHRM%29_Dataype_Constants#.24effect.5Bconstant.5D|effect ef]])</strong><br />
Converts the ASH-based object into an item.<br />
Returns the desired association between skills and the effects that they produce.<br />
Accepts: string, int
<em>Sample</em>:[[%28ASHRM%29_Code_Samples#Sample_3:_Skill_upkeep|Skill_upkeep]]</p>
</p>


<p><strong>slot item_to_slot( [[%28ASHRM%29_Dataype_Constants#.24item.5Bconstant.5D|item it]] )</strong><br />
<p><strong>zodiac to_zodiac( variable )</strong><br />
Returns the natural slot for the item, if it is equippable.</p>
Converts the ASH-based object into a zodiac.<br />
Accepts: string
</p>
 
<p><strong>location to_location( variable )</strong><br />
Converts the ASH-based object into a location.<br />
Accepts: string, int
</p>
 
<p><strong>familiar to_familiar( variable )</strong><br />
Converts the ASH-based object into a familiar.<br />
Accepts: string, int
</p>
 
<p><strong>class to_class( variable )</strong><br />
Converts the ASH-based object into a class.<br />
Accepts: string
</p>
 
<p><strong>stat to_stat( variable )</strong><br />
Converts the ASH-based object into a stat.<br />
Accepts: string
</p>
 
<p><strong>skill to_skill( variable )</strong><br />
Converts the ASH-based object into a skill.<br />
Accepts: string, int, effect
</p>
 
<p><strong>effect to_effect( variable )</strong><br />
Converts the ASH-based object into an effect.<br />
Accepts: string, int, skill
</p>
 
<p><strong>slot to_slot( variable )</strong><br />
Converts the ASH-based object into a slot.<br />
Accepts: string, int, item
</p>
 
<p><strong>element to_element( variable )</strong><br />
Converts the ASH-based object into an element.<br />
Accepts: string, int
</p>
 
<p><strong>monster to_monster( variable )</strong><br />
Converts the ASH-based object into a monster.<br />
Accepts: string, int
</p>

Revision as of 16:00, 26 June 2007

Data Type Conversions

These functions will convert 1 type of data to another.

string to_string( variable )
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.
accepts: boolean, int, float, item, zodiac, location, familiar, class, stat, skill, effect, slot, element, monster

int to_int( variable )
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.
accepts: String, float, item, zodiac, location, familiar, skill, effect, slot, element, monster
may accept: boolean, class, stat

boolean to_boolean( variable )
Converts the ASH-based object into boolean.
Accepts: String
may accept: Int

float to_float( variable )
Converts the ASH-based object into a float.
Accepts: String
may accept: int

item to_item( variable )
Converts the ASH-based object into an item.
Accepts: string, int

zodiac to_zodiac( variable )
Converts the ASH-based object into a zodiac.
Accepts: string

location to_location( variable )
Converts the ASH-based object into a location.
Accepts: string, int

familiar to_familiar( variable )
Converts the ASH-based object into a familiar.
Accepts: string, int

class to_class( variable )
Converts the ASH-based object into a class.
Accepts: string

stat to_stat( variable )
Converts the ASH-based object into a stat.
Accepts: string

skill to_skill( variable )
Converts the ASH-based object into a skill.
Accepts: string, int, effect

effect to_effect( variable )
Converts the ASH-based object into an effect.
Accepts: string, int, skill

slot to_slot( variable )
Converts the ASH-based object into a slot.
Accepts: string, int, item

element to_element( variable )
Converts the ASH-based object into an element.
Accepts: string, int

monster to_monster( variable )
Converts the ASH-based object into a monster.
Accepts: string, int