Macros

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 macros 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.)

Example:

<<display "Another Passage">>

Harlowe

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.

Example:

(font: “Arial”)[This text will be in Arial.]

Snowman

Snowman does not provide macros in the same sense that SugarCube and Harlowe do, but allow mixing JavaScript code in text with <% and %>, with <%= and %> displaying the result on the page.

Examples

The chalkboard reads 2 + 2 = <%= 2 + 2 %>.

results matching ""

    No results matching ""