TRUE
constant
Constant
integer TRUE = 1;Constant used to define the TRUE value in conditional structures or variables/constants in general. Usually it’s used because it is more readable, indicating a boolean value instead a integer value (1). However, this is an arbitrary distinction in LSL which uses integers to represent Boolean values anyway. It is probably better to consider TRUE and FALSE as mnemonic constants for the integer values 1 and 0.
Examples
Section titled “Examples”Example 1
integer q;
default{ state_entry() { q = TRUE; if(q) { llSay(0, "TRUE"); q = FALSE; if(!q) { llSay(0, "FALSE"); q = TRUE; if(!q) { llSay(0, "Won't say this"); } else { llSay(0, "TRUE"); q = FALSE; if(q)20 collapsed lines
{ llSay(0, "Won't say this"); } else { llSay(0, "FALSE"); } } } else { llSay(0, "Won't say this"); } } else { llSay(0, "Won't say this"); } }}- Note that all non-zero integers test as ‘true’ in statements such as “if (x) … ” but only the value 1 corresponds to
TRUEas in “if (x ==TRUE) …” - A double exclamation mark can be used to convert any ‘true’ or
FALSEinteger to BooleanTRUE/FALSEas in “integer Bool = !!value;”
See also
Section titled “See also”Constants
Section titled “Constants”| Constant | Type | Value | Description |
|---|---|---|---|
FALSE |
Articles
Section titled “Articles”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.