To int: Difference between revisions
Jump to navigation
Jump to search
imported>Heeheehee m Locations all return 0 when converted to integers, so that's not the greatest example there. |
imported>Zarqon mNo edit summary |
||
Line 23: | Line 23: | ||
** 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 | ||
* special datatypes (class, skill, etc.) return their ID | * special datatypes (class, skill, etc.) return their ID number as referenced in KoL, with the exception of monsters and locations, which always convert to 0. | ||
| | | | ||
Revision as of 13:54, 30 April 2010
needs(code_samples);
Function Syntax
int to_int( 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, skill, etc.) return their ID number as referenced in KoL, with the exception of monsters and locations, which always convert to 0.