例1:
function num(a)
if a=="我爱虫虫教学!" then
print ("你是好学员!")
else
print ("你最好能来学习!")
end end
c ="我爱虫虫教学!"
num(c)
如果我们的 c= 的是另外的字符串,则输出的的是 "你最好来学习!"
例2:
local today=1
if today==1 then
print("今天是星期一")
elseif tody==2 then
print("今天是星期二")
elseif tody==3 then
print("今天是星期三")
elseif tody==4 then
print("今天是星期三")
elseif tody==5 then
print("今天是星期三")
elseif tody==6 or tody==7 then
print("今天休息日")
else
print("地球没有星期八,你快回太空去吧!")
end
在这里局部变量,"today="你后面输几,它就会显示星期几
例3:
学校成绩编程:
local cj=98
if cj<=100 and cj>=90 then
print("优秀")
elseif cj<90 and cj>=70 then
print("良好")
elseif cj<70 and cj>=60 then
print("及格")
elseif cj<60 and cj>0 then
print("不及格")
else
print("你的成绩有误")
end