Bool: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mindraker
>NXTBoy
Flipped redirect
 
(38 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{CatUp|Properties}}
#REDIRECT [[Boolean]]
 
== Introduction ==
A Bool, or Boolean Value is a <b>true</b> or <b>false</b> value. In Lua, either the value is <b>true</b>, or it is <b>false</b>/<b>nil</b>. When trying to change this value in code, use a <b>true</b> or a <b>false</b> variable.
 
These variables show up as a checkbox in the Properties window. <b>True</b> is a checked box, <b>false</b> is an unchecked box.
 
== Examples ==
<pre>
x = true
print(x)
Will result in:
true
 
x = true
print(not x)
Will result in:
false
 
print(not false)
Will result in:
true
</pre>
 
Boolean values are used to represent the results of logic tests. The equals ==, and not equals ~= operators will return boolean values depending on the values supplied to them.
<pre>
print(1 == 0) -- test whether two numbers are equal
Will result in:
false
 
print(1 == 1)
Will result in:
true
 
print(1 ~= 0) -- test whether two numbers are not equal
Will result in:
true
 
print(true ~= false) -- is true not equal to false?
Will result in:
true
</pre>
 
 
== See Also ==
 
[[RBX.lua.BoolValue (Object)]]
 
[http://www.lua.org/pil/2.2.html Programming in Lua 2.2: Booleans]
 
[http://lua-users.org/wiki/LuaTypesTutorial Lua Types Tutorial]
 
[[Category:Properties]]

Latest revision as of 15:28, 10 July 2011

Redirect to: