Bool

From Goodblox Wiki
(Redirected from Boolean)
Jump to navigationJump to search


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