![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Lua
文章平均质量分 63
Geek猫
这个作者很懒,什么都没留下…
展开
-
Lua 标准库
8个基本库 基本函数 http://www.lua.org/manual/5.1/manual.html#5.1 协程库 string库 table库 数字库 IO库 操作系统 调试库-- 断言语句,中断程序运行assert(false, "error") -- false时程序断言print("test")运行结果>...原创 2018-04-24 11:07:26 · 346 阅读 · 0 评论 -
Lua 编译之二
测试程序程序下载地址: https://download.csdn.net/download/youshijian99/10344466原创 2018-04-12 16:55:43 · 142 阅读 · 0 评论 -
Lua 语法
lua是区分大小写的lua注释 -- 单行注释 --[[ code --]] 块注释 ---[[code --]] 取消块注释dofile("lua脚本路径") // 执行lua脚本文件lua八种数据类型nil, boolean, number, string, function, userdata, thread, table.前面4种是非引用...原创 2018-04-12 14:41:18 · 501 阅读 · 0 评论 -
Lua 解释器参数传递
usage: lua [options] [script [args]].Available options are: -e stat execute string 'stat' 直接在命令行输入代码 -l name require library 'name' 加载库文件 -i enter interactive mode after executing 'script' ...原创 2018-04-12 14:36:35 · 1357 阅读 · 0 评论 -
Lua 编译
网址链接 Lua官方网址: http://www.lua.org/ Lua官方参考手册: http://www.lua.org/docs.html Lua中文参考手册: http://manual.luaer.cn/ Lua中文论坛: http://www.luaer.cn/ Lua下载: http://www.lua.org/ftp/Lua 最新版本二进制下载方法L...原创 2018-04-12 13:29:23 · 6610 阅读 · 0 评论 -
Lua 类
用表实现类机制例程1CPerson= {name="default name", age= 10, sex = "fale"}-- 构造方法function CPerson.new(t,o) o = o or {} setmetatable(o, t) t.__index = t -- 从一个表o中访问另外一个t表的元素,通过元表实现 return oend-- 方法funct...原创 2018-04-17 09:37:57 · 112 阅读 · 0 评论 -
Lua sciTE设置
安装目录 : Lua\5.1\SciTE\SciTEGlobal.properties修改 SciTEGlobal.properties 文件修改字体font.base=font:YaHei Consolas Hybrid,size:14修改背景修改背景颜色二:\Lua\5.1\SciTE\SciTEGlobal.properties import black 注释打开...原创 2018-04-12 12:42:34 · 1569 阅读 · 0 评论 -
Lua 弱表与垃圾回收机制
弱表weak表是一个表,它拥有metatable,并且metatable定义了 _mode 字段weak表中的引用是弱引用,弱引用不会导致对象的引用计数变化。如果一个对象只有弱引用指向它,那么垃圾回收(gc)会自动回收该对象的内存。_mode 字段可以取3个值: k v kvk v 是表的键值, 都属于weak,任何情况下只要有一个被gc回收,那么 k v 都会被从表中移除例程t = {}t...原创 2018-04-17 10:30:14 · 720 阅读 · 0 评论 -
Lua 环境
查看_G表中内容for k, v in pairs(_G) do print(k, v)end运行结果 string table: 0042DFA8xpcall function: 0042E7C0package table: 0042DC60tostring function: 0042E720print function: 00247660os table: 0042DF30unpack ...原创 2018-04-15 14:34:39 · 350 阅读 · 0 评论 -
Lua 元表
例程a = {1, 2, 3}b = {2, 3, 4}mt = {}mt.__add = function(a,b) local len = table.getn(a); local res = {} for i = 1, len do res[i] = a[i] + b[i] end return resendsetmetatable(a, mt)setmetat...原创 2018-04-15 14:26:42 · 183 阅读 · 0 评论 -
Lua table 扩展数组、链表
数组特点:通过下标访问。lua table直接下标访问就可以实现数组例程tab = {2, 3, 4, 5}print(tab[1], tab[2], tab[3], tab[4])运行结果2 3 4 5例程tab = {{2, 3, 4, 5},{9,8,7}}print(tab[1][1], tab[1][2], tab[1][3], tab[1][4])print(tab[2][1],...原创 2018-04-14 23:25:32 · 1124 阅读 · 0 评论 -
Lua 协程
例程function func() print("hello")endco = coroutine.create(func)print(coroutine.status(co)) -- 查看协程状态coroutine.resume(co)运行结果suspendedhello例程function func(a,b) print(a,b)endco = coroutine.crea...原创 2018-04-14 22:40:42 · 132 阅读 · 0 评论 -
Lua 函数
function add(a,b) return a + bendsub = function(a, b) return a - bendprint(add(1, 2))print(sub(1, 2))运行结果3-1tab = {}tab.square = function(a) return a * aendprint(tab.square(2))运行结果4tab = {}...原创 2018-04-14 21:39:49 · 166 阅读 · 0 评论 -
Lua C API
Lua语言是如何与Lua C语言通信的? lua利用虚拟栈与C进行数据交换。在栈中的每个元素都表示一个值(nil, string, number etc) 利用栈进行数据交换,数据采用先进后出原则。 Lua 的每个元素有两种序号进行编号。 Lua如何操作堆栈的往栈里压值void lua_pushboolean (lua_State *L, i...原创 2018-05-02 17:54:56 · 225 阅读 · 0 评论