
lua 条件控制
if 语句
结构
if (condition)
then
statements
end示例程序
local a = 10 if (a > 1)
then
print("if condition")
end
if … else … 语句
结构
if (condition)
then
statements
else
statements
end示例程序
local a = -1 if (a > 10)
then
print("if condition")
else
print("else condition")
end
if … elseif … 语句
结构
if (condition)
then
statements
elseif (condition)
then
statements
else
statements
end示例程序
local a = 10 if (a > 20)
then
print("if condition")
elseif (a > 1)
then
print("elseif condition")
else
print("else condition")
end