From ZCWiki
Jump to navigationJump to search

The keyword bool is used to define variables as boolean types (having a value of either true or false) and to indicate that functions return boolean values.


The first example demonstrates how to declare boolean variables.

bool Link_Is_OK = true;

The second example demonstrates how to declare a function that returns a boolean value.

bool StillAlive(){
  return Link->HP > 0;


Variables defined as bool can store a value of true or false, and can be used in logical (boolean) expressions.

ZScript (like the C programming language) will consider any non-zero number to have a true value. Thus, the following code is valid (even if it doesn't make too much sense):

  // The statements in this block will
  // always be executed, because
  // the number 42 always has a
  // value of true.

Note that the compiler will give you a warning, but the script will compile and execute as noted above. See typecasting for additional details.

See Also