|
|
(10 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| {{CatUp|Data 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'''.
| |
| | |
| {{LeftNoticeStart}}
| |
| One easy way to think of Boolean values is as a light switch. A switch has two positions, on and off. So when you flip the switch, you change it from one to the other.
| |
| | |
| The same idea works with bools, and you may also hear people say things like "flip the switch to true", or something similar. This is because a lot of people think of bools as switches.
| |
| |}
| |
| | |
| | |
| | |
| 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
| |
| </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]]
| |
| [[Category:Data Types]]
| |