18,700
edits
m (→Relational: typo) |
(→bool: bools are buggy in Windows) |
||
Line 448: | Line 448: | ||
===bool=== | ===bool=== | ||
A [[wikipedia:Boolean data type|Boolean]] number has one of two possible states. Thus, a bool can be either 1 or 0. You can also use the keywords "true" and "false". | '''(Note: See warning at bottom of this section; bools are not recommended.)''' A [[wikipedia:Boolean data type|Boolean]] number has one of two possible states. Thus, a bool can be either 1 or 0. You can also use the keywords "true" and "false". | ||
var bool example = | var bool example = true; | ||
func bool are_we_there_yet(void) | func bool are_we_there_yet(void) | ||
{ | { | ||
Line 456: | Line 456: | ||
} | } | ||
Giving a bool any value other than 0 | Giving a bool any value other than 0 or "false" will set it to 1 or "true". For instance, assigning a float to a bool will make the bool "true" or "1" unless the float value is "0.0", which will become "false". On Macs, you can make reference to bools without any relational operator. The following statements are equivalent in Mac Oni: | ||
if (example) | |||
if (example eq true) | |||
However, Windows Oni will fail to evaluate bare references to bools, and testing indicates the possibility of other bugs existing in Windows Oni's handling of bools. Additionally, Bungie West uses virtually no bools in Oni's scripts. Since ints are handled much more reliably, it's recommended to use ints instead of bools, assigning them the values 1 and 0 to represent "true" and "false". | |||
===int=== | ===int=== |