语法没有分号
打印函数: print("hello world! ")
print(“hello”,“world”) //print里面可以列多项元素
五种变量类型nil,Boolean,string,Number,table //table是数组,没有0号元素,从1开始
注释方法:
两个横杠–注释一行
这样 --[[ … ]] 注释多段
if语句:
if a<=3 then
xxxxxxx
else if a>9 then
xxxxxx
else xxxxx
end
while语句:
a=1; while a<=30 do
print(“Value of a:”,a,’\n’)
a=a+1
end
for语句:
for i=0,3 do
print(i) //it can reach to 3
end
repeal语句:
repeal
xxxxx
until a>5
print元素间拼接:
a=def;
print(“abc”…a)
函数:
function aa(str)–定义一个函数
print(“the trans function canshu is”,str)
end
aa(123)–调用函数
其它一些知识点:

本文介绍了Nodemcu开发中使用Lua脚本语言的基础知识,包括无分号语法、print函数、五种变量类型、注释方法、条件语句(if、else if、else)、循环结构(while、for、repeat-until)以及函数定义和调用。此外,还讲解了Lua中的逻辑运算符(and、or)和不等于操作符(~=`),并展示了数组的灵活使用方式。
最低0.47元/天 解锁文章
4524

被折叠的 条评论
为什么被折叠?



