lua基础知识(基于RUNOOB总结)

Dawnworld 2020-06-07

数据类型

nil(无效值,相当于false)

boolean

number(双精度浮点)

string:字符串

userdata:自定义类型

function(自定义类型)

thread :独立线程

table:键值对,相当于字典

table.concat (table , 两字符串间的连接字符, start , end):连接字符串的函数

变量

print

循环

print

流程控制

print

函数

print

运算符

print

字符串

print

数组

print

迭代器

print

表

print

模块和包

print

元素

print

协同程序

coroutine.create()     创建 coroutine,返回 coroutine, 传入参数是函数

coroutine.resume()   重启 coroutine,和 create 配合使用,返回值[ture/false,val1,val2...]

coroutine.status()           查看 coroutine 的状态,返回状态:dead,suspended,running

coroutine.wrap()       创建 coroutine,返回一个函数,直接调用,和 create 功能重复但有区别。

coroutine.running()        返回正在跑的 coroutine,返回线程号,返回值[主ture/非主false]

coroutine.yield()             挂起 coroutine,为suspended态,这个和 resume 配合使用,可返回值。

文件IO

print

错误处理

print

调试

print

垃圾回收

print

面向对象

print

数据库访问

print

 

相关推荐