How To Call It
Module is a global table: call its functions with a dot (Module.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.
Returns a sorted, detached array of defined module names; changing the list does not change the registry.
Documented for app version 1.0.50Updated:
Module is a global table: call its functions with a dot (Module.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.
Returns a sorted, detached array of defined module names; changing the list does not change the registry.
Names are dotted ASCII identifiers of 1–96 characters; each segment starts with a letter or underscore. A run allows up to 128 definitions and 32 dependency levels. A factory receives its name and must return a table or function. No source string, file or URL is loaded; imported library code must be present in the macro source.
Resolve dependencies with Module.use inside a factory. Initialization is lazy and successful exports keep their identity for the current run; a new run starts empty. Duplicate definitions and dependency cycles are errors. Failed factories are not cached and can be retried. Use Api.check for requirements; factory bodies remain subject to normal script policy checks.
The snippet below is a starter pattern that can be applied directly in runtime flow.
Module.define("example.normalizer", function()
return {clean = function(text) return string.lower(text) end}
end)
for _, name in ipairs(Module.list()) do print(name) endFrom foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
Module.define("example.normalizer", function()
return {clean = function(text) return string.lower(text) end}
end)
for _, name in ipairs(Module.list()) do print(name) endlocal stepOk = true
Module.define("example.normalizer", function()
return {clean = function(text) return string.lower(text) end}
end)
for _, name in ipairs(Module.list()) do print(name) end
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
Module.define("example.normalizer", function()
return {clean = function(text) return string.lower(text) end}
end)
for _, name in ipairs(Module.list()) do print(name) end
end)
if not ok then
print("API step failed: Module.list: " .. tostring(err))
requestStop()
end-- Module.list()
local function run_list_step()
Module.define("example.normalizer", function()
return {clean = function(text) return string.lower(text) end}
end)
for _, name in ipairs(Module.list()) do print(name) end
end
local ok, err = pcall(run_list_step)
if not ok then
toast("Step failed")
print(err)
endModule.define("example.normalizer", function()
return {clean = function(text) return string.lower(text) end}
end)
for _, name in ipairs(Module.list()) do print(name) end