define phrasebook, use phrasebook
A phrasebook groups phrase definitions into one named collection,
optionally gated by a while predicate. It carries no fixed meaning of
its own. It is simply a way to differentiate text by world state, and
whatever the predicate selects for is up to you: a narrative voice, a
mood, a chapter, or a location. Whichever declared book's while
predicate holds at render time supplies the text, matched first in
declaration order, per key. A predicate-less book is the default
phrasebook. It is active whenever no earlier book claims the key, and
it is the feature at its simplest: one named book with no predicates,
used only to group entries.
define phrasebook midnight-book while midnight
vane-mood, first-time:
The vane swings hard north, as if the night had opinions.
or
The vane holds north. Of course it does.
end phrasebook
define phrasebook evening-book
vane-mood, first-time:
The vane noses the evening breeze, unhurried.
or
The vane sits easy in the last of the light.
vane-quiet:
The vane keeps its own counsel.
end phrasebook
Entries are ordinary phrase definitions. Each takes the form
<key>[, strategy]: with or variants, and all five strategies apply,
verbatim included. The consuming side is unchanged: you write
phrase vane-mood in a clause body, or a {vane-mood} marker in prose.
At midnight the first book wins vane-mood, and at any other time the
default book supplies it. The default book covers vane-quiet alone, so
vane-quiet renders the same in every state. Fallthrough is per key,
never per book.
The compiler load-checks each of the following rules.
- Story text always wins. A story-wide
define phrase vane-mood(outside any book) beats every book, in every state; a per-entityphrase vane-mood:beats even that. Swapping books never changes text you wrote at those levels. - Story keys only. A book entry key is a single kebab-case word in
the story's own phrase namespace. A dotted platform message ID raises
analysis.phrasebook-dotted-key. To override a platform message, use a story-leveloverride message <alias>block (ADR-255). - The book's
whileis the only gate. An entry-levelwhileraisesanalysis.phrasebook-entry-gate. Split the entry into a second book instead. - Counters are per book.
first-time/cycling/stickystate belongs to the entry: two books'first-timetexts for the same key each fire their own "first", and both survive save/restore. - The active book is chosen at render. The choice happens when the turn's text renders, against the turn's final state. A turn that flips a predicate renders its whole output from the newly active book.
Two companion forms live outside the define phrasebook block, in the
story header and in imported files.
story "The Folly at Fernhill" by "The Sharpee Project"
use phrasebook candlewick-gothic while the player holds the locket
use phrasebook plain-country
import "voices/winter"
use phrasebook <name> [while <condition>] in the story header
activates a packaged phrasebook by name and binds the predicate at the
use site. You may write it any number of times, and an unknown name
raises analysis.unknown-phrasebook. import "voices/winter" at the top
level splices in a file of your own define phrasebook blocks. The file
on disk is voices/winter.chord, and its books take their arbitration
position at the import line. A phrasebook file is just one kind of
fragment, because import pulls in any
multi-file story source, not
only phrasebook blocks. Header use lines and spliced body blocks
arbitrate together, in file order.