Unofficial LSL Reference

[[types:boolean]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

types:boolean [2015-01-09 09:40 SLT]
sei Add filenames
types:boolean [2015-02-04 18:54 SLT] (current)
sei style, remove Boolean operator from See Also as we don't know what to do about that yet
Line 2: Line 2:
 ===== Boolean ===== ===== Boolean =====
  
-LSL does not support a boolean type per se; instead, its function is performed by an [[types/integer]]. When a variable or parameter is a boolean, it means that it's an integer which represents a truth value of //false// when it is zero, or //true// when it is not zero.+LSL does not support a boolean type per se; instead, its function is performed by an $lty[integer]. When a variable or parameter is a boolean, it means that it's an integer which represents a truth value of //false// when it is zero, or //true// when it is not zero.
  
-Note that the constant [[constants/TRUE]] has the value 1, but //any// value different to 0 (including negatives) will serve as a truth value of //true// for variables that represent a boolean value.+Note that the constant ​$lct[TRUE] has the value 1, but //any// value different to 0 (including negatives) will serve as a truth value of //true// for variables that represent a boolean value.
  
-It is not recommended to test boolean values against [[constants/TRUE]] or [[constants/FALSE]]. In most cases, that's not necessary. When the variables are properly named, they usually can be better read by omitting such comparisons. Consider the following example:+It is not recommended to test boolean values against ​$lct[TRUE] or $lct[FALSE]. In most cases, that's not necessary. When the variables are properly named, they usually can be better read by omitting such comparisons. Consider the following example:
  
 <file lsl2 boolexample1.lsl>​ <file lsl2 boolexample1.lsl>​
Line 50: Line 50:
 </​file>​ </​file>​
  
-The latter version is more compact, more readable, faster, and uses less memory. In short, it's better in all respects. It works, because when the argument to an [[lsl/if]] statement is an integer, any value distinct to 0 will be taken as true. The trick for readability is to decide the name of the variable depending on what it represents when the truth value is //true//; in the latter example, when the variable is true it will represent that the object is rotating, thus the choice ''​rotating''​ for the variable name.+The latter version is more compact, more readable, faster, and uses less memory. In short, it's better in all respects. It works, because when the argument to an $lkw[/if] statement is an integer, any value distinct to 0 will be taken as true. The trick for readability is to decide the name of the variable depending on what it represents when the truth value is //true//; in the latter example, when the variable is true it will represent that the object is rotating, thus the choice ''​rotating''​ for the variable name.
  
 ==== See also ==== ==== See also ====
-  * [[constants/integer]] type +  * $lty[integer] type 
-  * [[operators/​Boolean]] operators +  * $lkw[if] statement
-  * [[lsl/if]] statement+