Voxta docs

Variables

Declare a scenario's variables with their starting values, and keep its text out of scripts.

Variables hold a chat's numbers, text, lists and tables: health, gold, a quest's stage, an inventory. Scripts read and write them (chat.get('hp'), chat.set('hp', 30)), conditions read them ($hp > 0), and text reads them ({{ variables.hp }}).

The scenario's Variables tab declares them. Each has a name, a type and the value it starts at:

TypeStarts at, when left empty
Number0
Text""
True / falsefalse
List of textsan empty list. Add one item at a time
Tablethe rows you enter. See Tables

A new chat gets every declared variable before its initial flags and before any script runs, so scripts don't set starting values. A chat already going keeps its own values. The tab only sets them at the start of a new one. The search bar at the top finds a variable by its name, its value or its notes.

Tables

A Table holds rows with named, typed columns: an inventory, a list of weapons and their stats, a quest log. Each column is Text, Number or True / false. Add columns with + Column and the starting rows with + Row.

Check Key on one column to give each row a different value in it, such as an item's name. Scripts then find a row by that value, and upsertRow changes the row that has it or adds one. The tab shows an error for a bad column name, a number cell that is not a number, and two rows with the same key.

Check Indexed on a column that scripts find rows by, such as an item's kind. Finding rows by a value in it then takes no time, however many rows the table has. A key column is always indexed.

Scripts read a table with chat.table('inventory') (see Script API). Text reads its rows:

{{ for item in variables.inventory.rows }}- {{ item.name }} x{{ item.qty }}
{{ end }}

A HUD section's List from variable can name a table: it shows one item per row, read by column name (label, icon, qty, tooltip). The chat's Explore page shows each table as a grid.

A const table is a good fit for data the scenario reads but never changes, such as weapon stats. A table can have up to 1,000 rows.

Const

Const makes a variable the scenario's own text or data: room descriptions, a character's lines, tuning numbers. Scripts and text read it like any other, but:

  • Setting it from a script throws, and the player's app can't change it either.
  • It is never saved with a chat. Each chat reads it from the scenario, so fixing a typo here reaches chats already started.

Moving long text out of scripts into const variables keeps it editable without touching code. A place can tell one line at random from a const list with Lines from (see Stage Builder).

Server

Server keeps a variable from the player's app. Scripts and the text the server writes into prompts (contexts, a place's story, button labels) read it. Nothing is sent to the app, the chat inspector included.

What the app works out itself can't read a server variable: the HUD tab, a button's Disabled when condition, travel notes, and a place's Lines from. They see nothing there.

Const and Server combine: a const, server list is a block of text the scripts use and nobody else sees.

See also

On this page