To int: Difference between revisions
Jump to navigation
Jump to search
imported>StDoodle Created page with '{{ #vardefine:name|to_boolean}}{{ #vardefine:return_type|boolean}}{{ FunctionPage| name={{#var:name}}| function_category=Datatype Conversions| function1={{Function| name={{#var…' |
imported>StDoodle No edit summary |
||
Line 16: | Line 16: | ||
}}| | }}| | ||
function_description= | 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()]] | |||
* 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, location, etc.) return their ID # as referenced in KoL | |||
| | | | ||
Revision as of 23:57, 13 March 2010
needs(code_samples);
Function Syntax
boolean to_boolean( any anything)
- anything is any data type that KoLmafia uses
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
- 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, location, etc.) return their ID # as referenced in KoL