Bool: Difference between revisions

From Goodblox Wiki
Jump to navigationJump to search
(Created page with "{{CatUp|Properties}} == 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...")
 
mNo edit summary
 
Line 1: Line 1:
{{CatUp|Properties}}
{{CatUp|Data Types}}


== Introduction ==
== Introduction ==
Line 51: Line 51:
[http://lua-users.org/wiki/LuaTypesTutorial Lua Types Tutorial]
[http://lua-users.org/wiki/LuaTypesTutorial Lua Types Tutorial]


[[Category:Properties]]
[[Category:Data Types]]

Latest revision as of 10:49, 20 September 2021


Introduction

A Bool, or Boolean Value is a true or false value. In Lua, either the value is true, or it is false/nil. When trying to change this value in code, use a true or a false variable.

These variables show up as a checkbox in the Properties window. True is a checked box, false is an unchecked box.

Examples

x = true
print(x)
Will result in:
true

x = true
print(not x)
Will result in:
false

print(not false)
Will result in:
true

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.

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


See Also

GBX.lua.BoolValue (Object)

Programming in Lua 2.2: Booleans

Lua Types Tutorial