An if statement lets Lua choose between branches.

Conditionals

conditionals.lua
local temperature = 
local status = ""

if temperature >= 80 then
  status = "warm"
else
  status = "comfortable"
end

print("temperature=" .. temperature)
print("status=" .. status)
local temperature = 
local status = ""

if temperature >= 80 then
  status = "warm"
else
  status = "comfortable"
end

print("temperature=" .. temperature)
print("status=" .. status)
local temperature = 
local status = ""

if temperature >= 80 then
  status = "warm"
else
  status = "comfortable"
end

print("temperature=" .. temperature)
print("status=" .. status)
if statement An `if` statement runs one block when its condition is true and can use `else` for the other case.