Boolean

From Bohemia Interactive Community
Revision as of 10:32, 30 June 2006 by Mikero (talk | contribs)
Jump to navigation Jump to search

Description: Boolean (true or false).

Boolean values in OFP are identical to numbers except, by convention, the values are 0, or 1. In fact, the engine when dealing with boolean variables (token-names) is happy with 0, and any other value.

Thus

StartEngine = 0; // would be interpred as off
IsNightTime = 1; // is not daytime !!!

as a covenience. well written mission.sqm's and well written config.cpp's (addons) have the following defines at top of file

#define true 1
#define false 0  // note the lack of a semicolon

Thus the script fragment

IsNightTime=true;

is exceedingly more readable, with the added bonus that not all token-names (IsNightTime) 'look' like boolean names. They could, appear to be, to the human reader, an integer that can take any value.