(set: VariableToValue) → Instant

Harlowe's version of the “set” macro, common to most Twine story formats.

Example usage:


In Harlowe, there are two kinds of variables. Normal variables, whose names begin with $, persist between passages, and should be used to store data that will be needed throughout the entire game. Temp variables, whose names begin with _, only exist inside the hook or passage that they're first (set:), and are forgotten after the hook or passage ends. You should use temp variables if you're writing passage code that mustn't accidentally affect any other passages' variables (by using (set:) on a variable name that someone else was using for something different). This can be essential in collaborative work with other authors working on the same story independently, or when writing code to be used in multiple stories.

Variables have many purposes in Harlowe: keeping track of what the player has accomplished, managing some other state of the story, storing hook styles and changer, and other such things. You can display variables by putting them in passage text, attach them to hooks, and create and change them using the (set:) and (put:) macros.


In its basic form, a variable is created or changed using (set: variable to value ). You can also set multiple variables in a single (set:) by separating each VariableToValue with commas: (set: $weapon to 'hands', $armour to 'naked'), etc.

You can also use it in expressions on the right-side of to. Much as in other expressions, it's a shorthand for what's on the left side: (set: $vases to it + 1) is a shorthand for (set: $vases to $vases + 1).

If the destination isn't something that can be changed - for instance, if you're trying to set a bare value to another value, like (set: true to 2) - then an error will be printed. This includes modifying array - (set: (a:2,3)'s 1st to 1) is also an error.

See also:

(push:), (move:)