Boolean Values
Boolean Values
Section titled “Boolean Values”A boolean variable, for those of you not familiar with programming, is a variable that is either true or false. Normally, a value of 1 is considered “true” and a value of 0 is considered “false”. Many MUSH functions return either 1 if they are true or 0 if false. For example, the hasflag() function tests to see if an object has a certain flag set on it. If hasflag(<object>,<flag name>) is true (the object has the flag), it will return 1. If it is false, it will return 0.
Other functions expect to operate on boolean values. What they consider “true” or “false”, however, depends on the setting of the “tiny_booleans” config option (@config tiny will show this).
Boolean configuration
Section titled “Boolean configuration”If tiny_booleans is…
no FALSE: null string, 0, any negative db
TRUE: everything else
yes TRUE: numbers other than 0, strings beginning with numbers other than 0
FALSE: everything else
Or, put another way:
Value tiny_booleans=no tiny_booleans=yes Gotcha
0 FALSE FALSE
non-zero number TRUE TRUE
#
null string FALSE FALSE
0<non-numbers..> TRUE FALSE *
<non-numbers…> TRUE FALSE *
Boolean examples
Section titled “Boolean examples”Examples (assuming tiny_booleans is “no”):
not(foo) = 0
not(<null string>) = 1
not(-66) = 0
not(0) = 1
not(#-1) = 1
not(#12) = 0
And so on…
(note: These rules only apply when a function expects a Boolean value, not for strings that expect other values.)
::: seealso