Skip to content

Lua code

Lua runs as Lua 5.4 compiled to WebAssembly. It is the lightest of the seven languages: ideal for a short transformation.

SymbolRole
inputThe value received on the input port
varsA table of the run variables
print(...)Writes to the execution log (arguments joined by tabs)
returnThe value returned leaves on the result port
local commandes = input.commandes
local total, nombre = 0, 0
for _, commande in ipairs(commandes) do
if commande.statut == "payee" then
total = total + commande.montant
nombre = nombre + 1
end
end
print(string.format("%d commandes payées, total %.2f €", nombre, total))
return { nombre = nombre, total = total }
  • Lua tables are indexed from 1: input[1] is the first element of a list you receive.
  • A table with consecutive numeric keys comes back out as a JSON array; a table with textual keys comes out as an object.
  • The standard library is available: string, table, math, os.

The packages field accepts pure-Lua source LuaRocks modules. They are resolved on the first run then injected offline afterwards.