Logic

Lua knows three logical operators;,  , and. These operators are used to create conditional statements that return true or false. In Lua, false and nil are considered falsey, all other values are considered truthy.

not
not is a logic operator that will negate conditions. Conditions considered  will become   and vice versa.

print(not true) will output print(not false) will output

and
and is a logic operator that will evaluate two conditions, and returns  only when both conditions are.

print(true and false) will output print(true and true) will output

or
or is a logic operator that will return  if any of the given two conditions are.

print(false or false) will output print(false or true) will output

ternary
The conditional (ternary) operator is equivalent to a one line if-else statement. It encompasses two of our previously used logic operators: and and or.

will set  to   will set   to