if 语句
x = 1
if x==1 then
print("1")
elseif x==2 then
print(2)
else
print("other")
end
while 语句
x = 1
while (x < 5) do
print("while循环")
x = x+1
end
for 语句
-- 数值for循环 for i=1, 10, 2 do print("i="..i) end-- 泛型for循环,类似C#或java中的foreach a = {"one", "two", "three"} for i, v in ipairs(a) do print(i, v) end
repeat until 语句
x = 1 repeat print(x) x = x + 1 until(x > 5)--当条件为真是退出循环