To int

From Kolmafia
Revision as of 11:35, 26 January 2015 by 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....)
Jump to navigation Jump to search
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.