1.数据类型

boolean——布尔;

number——整型浮点型;

nil——null;

string——字符串;

function——函数(既可以函数声明关键字,也可以当委托使用);

userdata——之后单独分析;

thread——线程;

table——表(索引从1开始);

metatable——元表;

2.变量

loacl——局部变量;

...——字符串拼接(不能使用+号,+会将字符串转为number在相加);

type()——typeof();

3.循环

while(condition)
do
   statements
end

for var= start,last,step do  
    <执行体>  
end  

//do while()
repeat
   statements
until( condition )

4.流程控制

if (condition) then
	statements
end

if (condition1) then
    statements
else if(condition2) then
    statements
else
    statements
end
    
if(condtion) then
   	if(condition2) then
   		statements
    end
end

5.迭代器

table t = {1,2,3,4,5}
for k, v in pairs(t) do
    print(k, v)
end

相关文章:

  • 2021-08-27
  • 2022-01-28
  • 2021-09-26
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2021-09-20
  • 2021-10-07
  • 2021-11-08
  • 2022-12-23
  • 2021-10-11
相关资源
相似解决方案