Bool

From Goodblox Wiki
Revision as of 07:26, 23 June 2020 by Pizzaboxer (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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