Lua
跳转到导航
跳转到搜索
lua 的变量名不支持中文。
字符串操作
match = line:match('^CPU Temperature: [+-](%S+)')
-- match 是第一个捕获组或者整个匹配的内容
IO 操作
local fc = ''
local f = io.popen("sensors")
for line in f:lines() do
local match = line:match('^CPU Temperature: [+-](%S+)')
if match then
print(match)
end
end
f:close()
不支持的特性
- sleep
continue
语句
环境变量
LUA_PATH
- 查找lua模块文件的路径,以分号分隔,如
/home/lilydjwg/scripts/lua/?.lua
。注意与Python不同,这里不是目录 LUA_CPATH
- 模块C模块文件的路径,格式同上
LUA_USE_READLINE
- 如果被设置,官方的 Lua 命令行将使用 readline,同时支持文件名补全。[1]
问题处理
luadoc 找不到 luadoc
模块
设置如下环境变量即可
LUA_PATH='/usr/share/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua'
第三方库
- penlight。注意:这是 AUR 中名为 penlight 的那个,不是 lua-penlight
- kikito/inspect.lua,Human-readable representation of Lua tables
参见
外部链接
- Lua 5.3 中文手册
- Lua Cheat Sheet
- Lua常见问题回答 Lua FAQ non-official | 孩子气 | C++, Lua, 大连,程序员
- lua.vim, Lua file type plug-in for the Vim text editor
- lua-users wiki: Interactive Lua(即 ilua)
- MoonScript, a language that compiles to Lua
- 编写高性能的Lua代码 | Tim's Blog
- Mare - Lua 5.3 调试器
- Can't add lua support while compiling · Issue #973 · vim/vim · GitHub: 为什么 Lua 的安装位置那么奇怪并且难以确定。