WikilyWIKILY
All games8 Wikis · pick your game
Menu

Documentation

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

A Dataset variable does not stand for one value: it points at a whole table, which a script reads as a list of rows.

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.

  1. Open Manage, click Variables, then Add variable.
  2. Name it, for example creatures, and pick Dataset.
  3. 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

Read-onlyA script can never write back to a table.
Your wiki onlyA script can never reach another wiki’s data.
CappedRow count and total size are limited. A few hundred rows sits comfortably inside.

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.

  1. Set Value type to Choice list.
  2. Under Choices from, pick A table column.
  3. 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.

One tableA row per creature: taming stats plus a foods JSON column listing what it eats.
Four reader inputsCreature, level, taming speed, elixir toggle. The creature list sources itself from the name column.
One Lua formulaA variable named tame does the work.

The script runs in three moves:

Find the rowif row.name == vars.creature then found = row end
Walk its foodsfor _, food in ipairs(found.foods) do ... end
Return the fieldsreturn { 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.

Next steps