To boolean: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Grotfang
mNo edit summary
imported>StDoodle
mNo edit summary
Line 34: Line 34:


}}
}}
{{RFI|It appears that most, but not all, of the special types are first converted to an int, then checked as per int rules:|Why the exceptions?|Doesn't this seem non-intuitive, especially for $class[seal clubber] vs. all others?}}

Revision as of 02:01, 11 March 2010

needs(code_samples);

Function Syntax

boolean to_boolean( any anything)

  • anything is any data type that KoLmafia uses

Datatype behaviour:

  • strings return false for anything except "true".
  • integers return true for anything except 0.
  • floats return true for anything except -1.0 to 1.0 (not inclusive).
  • locations return false.
  • items return true.
  • monsters return false.
  • skills return true.
  • effects return true.
  • elements return false for [none] but true for everything else.
  • slots return false for [hat] but true for everything else.
  • stats return true.
  • familiars return true.
  • classes return false for [seal clubber] but true for everything else.

Attention KoLmafia Experts!

We need your help; some details of this function's operation are unknown or unclear.

The following specific questions have been raised:

  • It appears that most, but not all, of the special types are first converted to an int, then checked as per int rules:
  • Why the exceptions?
  • Doesn't this seem non-intuitive, especially for $class[seal clubber] vs. all others?