Macros are Tea’s primary authoring tool—they let you set variables, branch on conditions, display dynamic content, respond to player input, and manipulate the page, all from within regular passage text. Every macro is written between double angle brackets:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
<<macroname>>.
Syntax
Macros come in two structural forms: void macros, which are self-closing, and container macros, which wrap content between an opening and a closing tag.<</macroname>>.
Argument types
Macros fall into two broad categories based on what kind of arguments they accept. Expression macros (e.g.<<set>>, <<print>>) evaluate their entire argument string as a single TwineScript or JavaScript expression:
<<link>>, <<audio>>) treat whitespace-separated tokens as individual arguments. Variable substitution happens automatically, so $gold passes the value of $gold, not the name "$gold". When a macro needs the variable’s name instead (for example <<textbox>>), you must quote it:
`) causes its contents to be evaluated and yielded as a single argument:
Macro categories
Variables & Scripting
Set and unset story variables, capture loop values, run arbitrary expressions, and embed raw JavaScript or TwineScript blocks with
<<set>>, <<unset>>, <<capture>>, <<run>>, and <<script>>.Display & Control
Output expressions, include passages, suppress whitespace, type text character-by-character, branch with
<<if>>, loop with <<for>>, match with <<switch>>, navigate with <<goto>>, and schedule delayed content with <<timed>> and <<repeat>>.Interactive
Create player-driven links, buttons, inline text-reveal macros, and form controls: checkboxes, radio buttons, text boxes, cycling links, and listboxes.
Audio
Load, group, playlist, and control audio tracks with
<<cacheaudio>>, <<audio>>, <<createaudiogroup>>, <<createplaylist>>, <<masteraudio>>, <<playlist>>, and friends.DOM
Manipulate live page elements after render: add, remove, or toggle CSS classes, and append, prepend, replace, copy, or remove element content with CSS/jQuery selectors.
Quick-reference table
| Category | Key macros |
|---|---|
| Variables & Scripting | <<set>> <<unset>> <<capture>> <<run>> <<script>> |
| Display & Control | <<print>> <<= >> <<- >> <<include>> <<nobr>> <<silent>> <<type>> <<do>> <<redo>> <<if>> <<for>> <<switch>> <<goto>> <<repeat>> <<timed>> <<done>> |
| Interactive | <<link>> <<button>> <<linkappend>> <<linkprepend>> <<linkreplace>> <<back>> <<return>> <<checkbox>> <<radiobutton>> <<textbox>> <<textarea>> <<numberbox>> <<cycle>> <<listbox>> |
| Audio | <<cacheaudio>> <<audio>> <<createaudiogroup>> <<createplaylist>> <<masteraudio>> <<playlist>> <<removeaudiogroup>> <<removeplaylist>> <<waitforaudio>> |
| DOM | <<addclass>> <<removeclass>> <<toggleclass>> <<append>> <<prepend>> <<replace>> <<copy>> <<remove>> |
Story
$variables are prefixed with a dollar sign and persist across passages. Temporary _variables are prefixed with an underscore and are reset on each new passage render. Both kinds can be used freely inside any macro expression.