
lua脚本无缩进但是有end结尾
if false or nil then
print("至少有一个是 true")
else
print("false 和 nil 都为 false")
end
if 0 then
print("数字 0 是 true")
else
print("数字 0 为 false")
end#在对一个数字字符串上进行算术操作时,Lua 会尝试将这个数字字符串转成一个数字#字符串变量for var=exp1,exp2,exp3 do
<执行体>
end while( true )
do
print("循环将永远执行下去")
endfor i = 10, 1, -1 do
repeat
if i == 5 then
print("continue code here")
break
end
print(i, "loop code here")
until true
endfor i=1, 3 do
if i <= 2 then
print(i, "yes continue")
goto continue
end
print(i, " no continue")
::continue::
print([[i'm end]])
endoptional_function_scope function function_name( argument1, argument2, argument3..., argumentn)
function_body
return result_params_comma_separated
end
optional_function_scope: 该参数是可选的制定函数是全局函数还是局部函数,未设置该参数默认为全局函数,如果你需要设置函数为局部函数需要使用关键字 local。
function_name: 指定函数名称。
argument1, argument2, argument3..., argumentn: 函数参数,多个参数以逗号隔开,函数也可以不带参数。
function_body: 函数体,函数中需要执行的代码语句块。
result_params_comma_separated: 函数返回值,Lua语言函数可以返回多个值,每个值以逗号隔开。require "<模块名>"https://www.runoob.com/lua/lua-tables.html
https://www.runoob.com/lua/lua-object-oriented.html