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