Lua中的子模
我不明白如何在Lua中使用子模块 例如,假设有一个模块“example”和“SubExample”。有以下几点认识:Lua中的子模,lua,Lua,我不明白如何在Lua中使用子模块 例如,假设有一个模块“example”和“SubExample”。有以下几点认识: "Example": -------------- local Example={}; function Example.launch(f) local sbEx = require('Module:SubExample') sbEx(f.args[1]) end return Example -------------- "SubExample": --------
"Example":
--------------
local Example={};
function Example.launch(f)
local sbEx = require('Module:SubExample')
sbEx(f.args[1])
end
return Example
--------------
"SubExample":
--------------
return function (argument)
return argument
end
--------------
它必须返回传输的内容
好的。但是,如果“SubExample”,如何从“SubExample”调用“Example”中的函数将采用这种样式:
local SubExample={};
function SubExample.retArgument(f)
return f
end
return SubExample
那么,如何从子示例中调用“Example”函数restargument呢?sbEx.restargument(f.args[1])
sbEx.restargument(f.args[1])