To int: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
thrall
imported>Eliteofdelete
Updated....seems to have a formatting issue where I can't go above 5 functions. Not sure how to get the other 4 to show up....
Line 11: Line 11:
return_type={{#var:return_type}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
return_also={{#var:return_also}}|
parameter1= '''any''' {{pspan|anything}}|
parameter1={{Param|boolean|convert}}|
p1desc={{Pspan|anything}} can be of most data types that KoLmafia uses|
}}|
 
function2={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|float|convert}}|
}}|
 
function3={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|string|convert}}|
}}|
 
function4={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|item|convert}}|
}}|
 
function5={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|class|convert}}|
p1desc={{Pspan|convert}} is the boolean, int, string, item, class, effect, familiar, skill, or thrall to convert|
}}|
 
 
function6={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|familiar|convert}}|
}}|
 
 
 
function7={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|effect|convert}}|
}}|
 
 
function8={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|skill|convert}}|
}}|
 
function9={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|thrall|convert}}|
}}|
}}|


function_description=This function looks for the best integer match to the specified input, which varies by datatype.
function_description=This function looks for the best integer match to the specified input, which varies by datatype.
* void causes an abort (it cannot be converted)
* boolean values return 0 for false and 1 for true
* boolean values return 0 for false and 1 for true
* float values return the same as they would with [[truncate|truncate()]]
* float values return the same as they would with [[truncate|truncate()]]
Line 22: Line 89:
** fully numeric strings, optionally with + or - as the first character, return as they would for a float (commas are also ignored)
** fully numeric strings, optionally with + or - as the first character, return as they would for a float (commas are also ignored)
** all other strings return 0, with a message saying that the string is not a valid integer
** all other strings return 0, with a message saying that the string is not a valid integer
* buffer always return 0 regardless of value, so you must convert the data to a string.
* special datatypes (class, skill, thrall etc.) return their ID number as referenced in KoL.
* special datatypes (class, skill, thrall etc.) return their ID number as referenced in KoL, with the exception of monsters and locations, which always convert to 0.
|
|



Revision as of 11:35, 26 January 2015

needs(code_samples);

Function Syntax

int to_int(boolean convert )

int to_int(float convert )

int to_int(string convert )

int to_int(item convert )

int to_int(class convert )

  • convert is the boolean, int, string, item, class, effect, familiar, skill, or thrall to convert

This function looks for the best integer match to the specified input, which varies by datatype.

  • boolean values return 0 for false and 1 for true
  • float values return the same as they would with truncate()
  • string values are parsed in several ways:
    • fully numeric strings, optionally with + or - as the first character, return as they would for a float (commas are also ignored)
    • all other strings return 0, with a message saying that the string is not a valid integer
  • special datatypes (class, skill, thrall etc.) return their ID number as referenced in KoL.