Macros allow programming code to be intermixed with text shown onscreen. They allow a wide variety of functionality to be added to a story, from changing the appearance of text to reacting to mouse and touch events. Story Formats are often chosen based on the macros they provide and how they can be used together.
Twine 1 and SugarCube
In Twine 1, macros were written with two less-than (
<<) and two-greater-than signs (
>>) around code. (SugarCube, as a successor of this form, follows the same syntax.)
<<display "Another Passage">>
The Harlowe story format uses a different syntax for macros. They are wrapped in a single open
( and close parenthesis
), and use brackets,
, to indicate which text or sections are associated or acted upon by the macro.
(font: “Arial”)[This text will be in Arial.]
%> displaying the result on the page.
The chalkboard reads 2 + 2 = <%= 2 + 2 %>.
largeFamily: cousins > 10 --