How To Call It
Workflow is a global table: call its functions with a dot (Workflow.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.
Processes a snapshot of a dense array in order, passing each value and index to the callback.
Documented for app version 1.0.50Updated:
Workflow is a global table: call its functions with a dot (Workflow.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.
Processes a snapshot of a dense array in order, passing each value and index to the callback.
items is a dense 1-based array; use action(value, index), intervalMs and timeoutMs. Order and item references are copied at entry; nested tables are not deep-copied. False breaks early and nil continues. The result has ok, reason, attempts, elapsedMs, value, values and error; values.n preserves the number of multiple returns, including nil. The default timeout is 30000 ms, with a maximum of 86400000 ms and up to 1000000 iterations. Calls are synchronous and cooperative; a blocking operation must still use its own timeout.
Combine API calls, conditions and reusable Module functions. Stop, pause and execution budgets remain active. Retry actions must be safe to repeat; do not automatically repeat side effects such as payments or taps after an ambiguous network response.
The snippet below is a starter pattern that can be applied directly in runtime flow.
local result = Workflow.each({"scan", "report", "finish"}, function(value, index)
print(index, value)
end, {intervalMs = 50, timeoutMs = 2000})
print(result.ok, result.reason)From 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.
local result = Workflow.each({"scan", "report", "finish"}, function(value, index)
print(index, value)
end, {intervalMs = 50, timeoutMs = 2000})
print(result.ok, result.reason)local stepOk = true
local result = Workflow.each({"scan", "report", "finish"}, function(value, index)
print(index, value)
end, {intervalMs = 50, timeoutMs = 2000})
print(result.ok, result.reason)
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
local result = Workflow.each({"scan", "report", "finish"}, function(value, index)
print(index, value)
end, {intervalMs = 50, timeoutMs = 2000})
print(result.ok, result.reason)
end)
if not ok then
print("API step failed: Workflow.each: " .. tostring(err))
requestStop()
end-- Workflow.each(items, action, options?)
local function run_each_step()
local result = Workflow.each({"scan", "report", "finish"}, function(value, index)
print(index, value)
end, {intervalMs = 50, timeoutMs = 2000})
print(result.ok, result.reason)
end
local ok, err = pcall(run_each_step)
if not ok then
toast("Step failed")
print(err)
endlocal result = Workflow.each({"scan", "report", "finish"}, function(value, index)
print(index, value)
end, {intervalMs = 50, timeoutMs = 2000})
print(result.ok, result.reason)