LuaModule
lua module development syntax
Install / Use
/learn @CppCXY/LuaModuleREADME
LuaImport
引入
这是一个单文件的库,只需要在可搜索目录下require "luaImport"
测试
测试用例不能单独执行,需要用vscode 打开luaImport所在文件夹为工作区,然后执行mainTest
使用
想要使用import 必须在当前文件的开始写上 _ENV=module "当前模块的,从可搜索的根目录开始下来的路径" 而且只支持 "aaaa.bbbb.cccc" 这样的方式
import 语法:
import "*" :from "xxxxx"
从模块xxx导出所有可导出对象,到当前模块
import "*" :as "alias" :from "xxxxx"
从xxxx导入所有可导入对象到一个 alias 变量中
import {"a","b"} :from "xxxx"
从xxxx导入 a和b两个对象
import {"a","b"} as "c" :from "xxxxx"
从xxxx导入a,b到表 c中
from语法:
from "xxxxx"中 ,xxxx应该是从可搜索的根目录开始的且只支持 dot的方式
也支持相对路径,相对路径的语法开头必须是 "." 比如同目录下的 test
import "*" :from ".test"
"."代表当前目录
".."代表上级目录
"..."代表上上级目录以此类推
但是不允许层级大于可搜索的根目录,这会出错的
export语法:
export主要是用于 import"*"的形式,当使用这种形式的时候只会导入export指定过的变量
例子
--file a.lua
export "aaaa"
--file b.lua
import "*" :from ".a"
print(aaaa)
可以访问aaaa
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
