Lua with datasets
Updated 2026-07-24
A Lua script gets useful when it works off a whole table of your real data instead of numbers typed into the script by hand.
The Dataset variable
Unlike the other kinds, a Dataset variable does not stand for a single value. It points at one table, and a script reads it as a list of that table rows.
- Open Manage, click Variables, then Add variable.
- Name it, for example
creatures, and pick Dataset. - Choose the table it points at, then save.
The numbers stay in the table where they are easy to edit. Change the table and every page using it follows, with no edit to the script.
Reading rows in Lua
The list is an ordinary Lua sequence, and it starts at 1.
vars.creatures[1]The first row.#vars.creaturesHow many rows there are.for _, row in ipairs(vars.creatures) doWalks every one of them.row.nameEach row is a table of columns, read by name with a dot.row.foodsA JSON column comes through as a nested list you can loop the same way.Often you want one row: the one a reader picked. Loop the list and keep the match.
for _, row in ipairs(vars.creatures) do if row.name == vars.creature then found = row end end
Choices from a table column
A Reader input of type Choice list normally offers choices you type by hand. It can take them from a table column instead.
- Set Value type to Choice list.
- Under Choices from, pick A table column.
- Choose the table, then the column.
The list stays in sync with the table. Add a row and the choice list grows on its own, with nothing to re-type.
A worked example: a taming calculator
Everything a reader can pick lives in one place, and every number lives in the table.
foods JSON column listing what it eats.tame does the work.The script runs in three moves:
if row.name == vars.creature then found = row endfor _, food in ipairs(found.foods) do ... endreturn { f1_name = ..., f1_amount = ..., f1_time = ... }The page lays those out in a results table whose cells are plain tokens like {{ tame.f1_amount }}. Because the script reads the reader inputs, the whole table recomputes the moment a reader changes anything.
Nothing is hard-coded in the script. Every number lives in the table, so editing the table updates the calculator without anyone touching the Lua.






