--//============= for 循环
--[[
for a=1, 5, 2
do
print("Hello ")
end
]]
--//===========repeat util
--[[
a=1
repeat
print("Hello")
a=a+1
until a==5
]]
--//=============and or not
--[[
and 和 or的运算结果不是true和false,而是和它的两个操作数相关。
a and b:如果a为false,则返回a;否则返回b
a or b:如果 a 为true,则返回a;否则返回b
]]
--[[
print(4 and 5) -- 5
print(4 or 5 ) --4
print(nil and 13) --nil
print(false and 13) --false
print(nil or 15) --15
print(false or 9) --9
a= true
x= true and false or 7
print(x)
y= a and print("----true") or print("----false")
print(y)
]]
-- //============type 获得变量的类型
--[[
a=1
print(type(a))
b="Hello"
print(type(b))
c=true
print(type(c))
d=nil
print(type(d))
e={1,2,3}
print(type(e))
e="nihao"
print(type(e))
]]
--//============
--[[
a=12
b=12
if a==b then
print("a==b")
elseif a~=b then
print("a ~=b")
end
A=false
print(A)
c=
print(type(c))
A&
【Lua】【1】Lua游戏脚本语言入门之杂码
最新推荐文章于 2024-07-12 23:00:26 发布
本文介绍了Lua语言的基础语法,包括for循环、repeat-until结构、逻辑运算符and、or、not的使用,以及类型检查、条件判断、表格操作、函数定义等内容,适合初学者入门。
摘要由CSDN通过智能技术生成