![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Lua语言
乐意-天地人
在路上
展开
-
Lua程序设计 变长参数
Lua中的函数还可以接受不同数量的实参。例如:在调用print时可以传入一个、两个或多个实参。 function add(...) local s = 0 for i, v in ipairs{...} do --> {...} 表示一个由所有变长参数构成的数组 s = s + v end return s end print(add(3,4,5,...原创 2015-08-04 11:26:05 · 93 阅读 · 0 评论 -
编写高性能的Lua代码
[url]http://wuzhiwei.net/lua_performance/[/url]原创 2016-06-23 12:05:36 · 140 阅读 · 0 评论 -
Lua语言,Sublime自定义快捷键
设置Sublime自动提示功能,因为默认的ctrl+space跟系统输入法冲突。 可以在Key Buildings - User中增加 [ { "keys": ["alt+/"], "command":"auto_complete" }, { "keys": ["alt+/"], "command":"replace_completion_wi原创 2016-08-03 10:10:20 · 413 阅读 · 0 评论 -
Lua的元方法学习
在使用加法操作时,会查找__add元方法,那么,在调用table不存在的字段时,会调用__index元方法,这是一样的规则。 大家要记住这句话:__index用于查询,__newindex用于更新。 当调用了子表t1不存在的XXXX字段时,就会调用t1元表里的__index元方法,并且会传递table和字段名两个参数。 当试图给t1的sayHello字段赋值时,Lua判...原创 2016-08-03 10:10:55 · 121 阅读 · 0 评论 -
将字符串写的table转换成Lua可以识别的table
-- 字符串转table local function stringToTable(str) local b = loadstring("return "..str); t = b(); return t end local str = "{{0, 0}, {3.0, 0}, {-3.0, 0}, {0, -3.0}, {3.0, -3.0}, {-3....原创 2016-09-20 20:38:12 · 378 阅读 · 0 评论