Boolean: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''Description:'''
'''Description:'''
Boolean ([[true]] or [[false]]).
Boolean ([[true]] or [[false]]).
Boolean values in OFP are ''identical'' to [[Number|numbers]] except, by convention, the values are 0,  or 1
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.




[[Category: Types]]
[[Category: Types]]

Revision as of 11:20, 30 June 2006

Description: Boolean (true or false).

Boolean values in OFP are identical to numbers except, by convention, the values are 0, or 1

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.