if語句:
? ??????????if(true) ?//注意0和1都是true
????????????then
????????????????print("hehe")
????????????end //輸出hehe
if-else語句:
? ??????????if(false)
????????????then
? ? ????????????print("hehe")
????????????else
? ? ????????????print("haha")
????????????end ?//如果false輸出haha,如何true輸出hehe
循環(huán)語句:
? ??????????i=1
????????????while(i<10)
????????????do
? ? ? ? ? ? ????print("循環(huán)執(zhí)行")
? ????????????? i=i+1
? ? ? ? ? ?end //輸出9次循環(huán)語句
for循環(huán):
? ??????????for var=1,3,1 do ?//這句話是:var從1變到3铝量,以1為步長(zhǎng)古毛;步長(zhǎng)默認(rèn)為1
? ? ????????????print(var)
????????????end ?//輸出1删性,2,3
泛型for循環(huán):
? ? ? ? ? ? ? ?a = {"one", "two", "three"}
????????????????for i, v in ipairs(a) ?do????
????????????????????????print(i, v)
????????????????end ? ?//輸出1 one蝙搔;2 two捎拯;3 three