创建modul.lua 文件
eg
module ={}
module.str ="hello world"
local function bar()
print("hello bar ")
end
function module.foo()
io.write("hello foo\n")
bar()
end
return module
创建module_test.lua
require("module")
print(module.str)
print(module.foo())
执行结果
hello world
hello foo
hello bar
可以给加载的模块一个别名变量
local m =require("module")
print(m.str)
print(m.foo())