Bool: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
No edit summary
>NXTBoy
Flipped redirect
 
(37 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{CatUp|Value Types}}
#REDIRECT [[Boolean]]
 
== Introduction ==
A '''Boolean''', or '''Bool''' value is a very simple type of data. It can be either '''true''' or '''false'''. That's it. Either yes or no.
 
In Lua, everything that has a value is '''true''', unless it is '''nil''' or '''false'''.
 
 
 
Booleans are really easy to use. Like so:
{{CodeExample}}
MyBool = true
 
if MyBool then
:--If "MyBool" is true, this code is run.
else
:--If "MyBool" is false, this code is run.
end
|}
 
 
Bools can also be used as numbers. '''true''' is 1 and '''false''' is 0. Sometimes you will see scripts like this:
{{CodeExample}}
MyBool = 1
 
if MyBool == true then
:--This code is run, since MyBool is '''1''', and thus true.
else
:--This bit is not run, since MyBool is true, not false
end
|}
 
 
== 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: