随笔分类 - Lua
摘要:简单模式 r 以只读方式打开文件,该文件必须存在。 w 打开只写文件,若文件存在则文件长度清为0,即该文件内容会消失。若文件不存在则建立该文件。 a 以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。(EOF符保留) r+ 以可
阅读全文
摘要:1.创建并运行 (1)方法1 local r=coroutine.create( --创建 function (a,b) print(a+b) print('end') end ) coroutine.resume(r,3,5) --执行 (2)方法2 local r=coroutine.wrap(
阅读全文
摘要:1.创建模块 新建一个文件 Module.lua -- 文件名为 module.lua -- 定义一个名为 module 的模块 Module = {} -- 定义一个常量 Module.constant = "abc" -- 定义一个函数 function Module.func() print(
阅读全文
摘要:无状态迭代器 多状态迭代器 迭代器函数 string.gmatch(str, pattern)
阅读全文
摘要:一、注释 1.单行 --print("hello") 2.多行 --[[ print("hello") print("hello") print("hello") --]] 二、数据类型 1.nil 无值 可以用作清空数据 2.boolean false true nil 判断时为false 3.n
阅读全文
摘要:1.下载 http://luadist.org/ 2.配置环境变量 解压后配置环境变量 C:\lua\bin 3.测试 4.vscode安装lua 5.helloworld print("hello") 6.vscode上好用的lua插件 (1) 它的功能有 转到定义,查找引用,鼠标悬停,诊断,智能
阅读全文