Difference between revisions of "To boolean"

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
m
imported>Bale
m
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Datatype Conversions|
 
  
 
function1={{Function|
 
function1={{Function|
Line 29: Line 28:
 
see_also={{SeeAlso|to_int}}
 
see_also={{SeeAlso|to_int}}
 
}}
 
}}
 +
 +
[[Category:Datatype Conversions]]

Revision as of 05:20, 22 May 2010

needs(code_samples);

Function Syntax

boolean to_boolean( any anything)

  • anything is any basic data type that KoLmafia uses

Datatype behaviour: This function converts the supplied datatype to a boolean value. For strings, this means that it will return false for everything except "true". This is case-sensitive -- "TRUE" will still return false. For all other datatypes, it returns to_int(anything) != 0. More details:

  • As indicated, integers return true for anything except 0, even negative values.
  • floats return true for anything except -1.0 to 1.0 (not inclusive). This is because to_int(float) truncates the float.
  • locations and monsters all return false. For these datatypes, to_int() always returns 0.
  • elements, slots, and classes return true for everything except the value that converts to 0. This is [none] for elements, [hat] for slots, and [seal clubber] for classes.
  • Other mafia datatypes (effects, familiars, items, stats and skills) all return true. Note that for these datatypes, to_int([none]) returns -1.

    See Also

to_int()