大粨兔奶糖

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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
posted on 2017-04-13 13:49  大粨兔奶糖  阅读(329)  评论(0编辑  收藏  举报