Control Flow Details
Logical Guards
Lua combines conditions with and, or, and not.
Logical Guards
logical_guards.lua
local points =
local active = true
local status = ""
if active and points >= 10 then
status = "bonus"
else
status = "wait"
end
print("points=" .. points)
print("active=" .. tostring(active))
print("status=" .. status)
local points =
local active = true
local status = ""
if active and points >= 10 then
status = "bonus"
else
status = "wait"
end
print("points=" .. points)
print("active=" .. tostring(active))
print("status=" .. status)
local points =
local active = true
local status = ""
if active and points >= 10 then
status = "bonus"
else
status = "wait"
end
print("points=" .. points)
print("active=" .. tostring(active))
print("status=" .. status)
combined condition
A guard can require multiple facts before choosing the success branch.