User Tools

Site Tools


Sidebar

Passage markup

basics

coding

extra

list

section

whitespace

Macros

basics

colour

data structure

date and time

game state

live

maths

number

revision

saving

showing and hiding

string

styling

url

deprecated

Types of data

Special keywords

Special passage tags

harlowe:bind

A few macros that produce interactive elements, like (cycling-link:), have the ability to automatically update a variable whenever the player interacts with them. There needs to be a way to specify which variable these will update: simply giving the macro the variable itself, such as in `(cycling-link: $hat, “Poker visor”, “Beret”)`, won't work - the value that's currently inside `$hat` will be given instead, as one would expect for every other kind of macro. So, the `bind` keyword is needed to make your intent unambiguous: `bind $hat` produces a “bound variable”.

One can bind any kind of variable: story-wide variables like `$morality`, temp variables like `_glance`, and data values and positions inside them, like `$diary's 1st's event`. Once bound, the macro's element will set data to it automatically, as if by a series of unseen (set:)s or (move:)s.

Note that bound variables can't be (set:) into variables themselves, because there's no real point to doing so (and it could lead to a lot of undue confusion).

Operator Purpose Example
bind Binds the named variable on the right. bind $weapon, bind _hat, bind $profile's age
harlowe/bind.txt · Last modified: 2019/04/16 03:55 by l