The NPC and state-machine plugins
The NPC plugin (priority 100) walks every entity with the npc
trait, dispatches to the behavior its behaviorId names, and executes
what comes back: attacks, emotes, and movement (with npc-moved events
and witnessed variants a story can narrate). It also fires enter/leave
hooks when the player's action moved them, which is the greeting-guard
pattern. Built-ins: guard (stationary, attacks the visible player
when hostile), passive, and factory-made wanderers, followers, and
patrol routes; stories register richer behaviors. A Chord story gets
all of this without opting in, because NPCs are core: a person, a guard (or passive, wanderer with move-chance 50, follower,
patrol with route [ … ]) composes the built-ins directly, with
with-fields for movement permissions, routes, and chances.
Configuration lives on the trait; the deep-NPC layers (character
model, lucidity) tick here too.
The author writes:
create the Orchard
a room
east to the Cider House
Apple trees in crooked rows.
create the Cider House
a room
west to the Orchard
Presses, barrels, and the sweet reek of last year's crop.
create Mairead
aka warden
a person, proper, patrol with route [the Orchard, the Cider House]
pronouns she
in the Orchard
The orchard warden, mid-round.
create the player
starts in the Orchard
The player sees:
> look
Orchard
Apple trees in crooked rows.
You can see Mairead here.
> wait
Time passes...
> look
Orchard
Apple trees in crooked rows.
> wait
Time passes...
> look
Orchard
Apple trees in crooked rows.
You can see Mairead here.
Mairead walks her two-room route on the plugin's turns, silently by
default: the plugin emits the npc-moved events, and narrating them
(or not) is the story's choice.
The state-machine plugin (priority 75) evaluates declarative
machines (states, guarded transitions triggered by actions, events,
or conditions, enter/exit effects, terminal states), and it applies at
most one transition per machine per turn. A Chord story reaches it by
opting in: use state-machines in the story header, then define machine, which exposes the plugin's full depth, with Chord conditions
as guards and Chord bodies as effects. Writing define machine without
the use line is a compile error.
The author writes:
story "The Ferry" by "ref"
id: plugins-machine
version: 0.0.1
states: waiting, signaled
use state-machines
create the Slipway
a room
A cobbled slipway running down into grey water.
create the capstan
in the Slipway
A tarred capstan wound with ferry rope.
on turning it
phrase capstan-turns
You lean into the capstan and it comes round, pawls clacking.
end on
create the signal cord
aka cord
scenery, pullable
in the Slipway
A cord for ringing the bell on the far bank.
on pulling it
change the story to signaled
phrase cord-rings
Far across the water, a bell answers the cord.
end on
create the player
starts in the Slipway
define machine ferry
role capstan is the capstan
starts moored
state moored
when turning the capstan: casting-off
state casting-off
on enter
phrase rope-pays-out
end on
when signaled: underway
state underway, terminal
on enter
phrase ferry-underway
end on
end machine
define phrase rope-pays-out
The rope pays out and the ferry noses off the far bank.
end phrase
define phrase ferry-underway
The ferry is underway, beating slowly toward you.
end phrase
The player sees:
> turn the capstan
You lean into the capstan and it comes round, pawls clacking.
The rope pays out and the ferry noses off the far bank.
> pull the cord
Far across the water, a bell answers the cord.
The ferry is underway, beating slowly toward you.
Two trigger kinds in two turns: the action trigger fires the turn the
capstan turns (the on turning it clause makes the turn succeed
and the transition's on enter speaks in the same turn's output),
and the condition trigger fires the turn the cord's clause moves the
story to signaled.
It is worth being precise that Chord's states:/change/select on
still do not use it. Chord states are plain world-state values with a
forward-march ratchet (reversible opts out); they give the effect of a
simple state machine without the plugin's machinery (no enter/exit
effects, no terminal states, no multi-machine registry). Dungeo's
death-penalty policy (the veto window) is a real state machine; the cloak's
states are Chord world-state.