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:event

(event: Lambda) → Changer

Hooks that have this changer attached will only be run when the given condition becomes true.

Example usage:

(event: when time > 5s)[Oops, I forgot the next link: [[Go east]].]

Rationale:

While the (live:) macro is versatile in providing time-based text updating, one of its common uses - checking if some variable has changed using (if:), and then displaying a hook and stopping the macro with (stop:) - is rather cumbersome. This macro provides that functionality in a shorter form - the example above is equivalent to: {(live: 0.2s)[ (if: time > 5s)[ Oops, I forgot the next link: [[Go east]]. ] ]}

Details:

This macro only takes a “when” lambda, which is like a “where” lambda but with “where” changed to “when” for readability purposes. This lambda doesn't have a temp variable before “when” - it doesn't iterate over anything, except, perhaps, moments in time.

Because (event:) hooks only run once, the (stop:) macro is unnecessary here.

Currently, you cannot attach (event:) to a command (such as in (event: when $a is 1)(link-goto:"?")). You have to wrap the command in a hook (such as (event:when $a is 1)[(link-goto:"?")]).

See also:

harlowe/event.txt · Last modified: 2019/04/16 03:07 by l