To int: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
buffer info
imported>Bale
r10782
Line 12: Line 12:
return_also={{#var:return_also}}|
return_also={{#var:return_also}}|
parameter1= '''any''' {{pspan|anything}}|
parameter1= '''any''' {{pspan|anything}}|
p1desc={{Pspan|anything}} is any data type that KoLmafia uses|
p1desc={{Pspan|anything}} can be of most data types that KoLmafia uses|
}}|
}}|



Revision as of 21:48, 13 March 2012

needs(code_samples);

Function Syntax

int to_int( any anything)

  • anything can be of most data types 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
  • buffer always return 0 regardless of value, so you must convert the data to a string.
  • 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.