Sound, music, and images
A story declares its media assets once, by name, and then plays or shows
them from any statement body. The files live under the project's assets/
directory and ship with the browser build; a client that cannot play a
kind of media simply ignores the cue, and the when client has …
condition lets the story say something else instead.
Declaring assets
define sound night-wind from "audio/night-wind.wav"
define sound boiler-thump from "audio/boiler-thump.wav"
define music dawn-theme from "audio/dawn-theme.wav"
define image folly-photograph from "images/folly-photograph.png"
Three kinds: a sound is a one-shot cue, music is a track, an
image is a picture. The path is relative to assets/. Every play or
show names one of these declarations, and the compiler checks the name
and the kind — a play music of a define sound is a diagnostic, and a
misspelled asset carries a nearest-match suggestion.
Sounds in the world
A sound is heard in the world as well as on the player's speakers. play sound plays the file, if it has one, and also makes the sound in the room
of the block it is written in. A listener, which can be a person or a
thing, reacts with after hearing the <sound> in its own block, in the
same turn, if the sound carries far enough to reach it. A sound with no
file is heard in the world and played on no speaker.
define sound depot-klaxon
create the call button
a thing, scenery, pushable
in the Loading Dock
after the player pushing
play sound depot-klaxon
end after
create the loader robot
a person, listener
in the Loading Dock
after hearing the depot-klaxon
move the mail sack to the Loading Dock
phrase robot-fetches-sack
end after
How far a sound carries, through open exits and past walls, is the
platform's to work out; a story only says who listens. hearing takes no
on form, since a sound cannot be refused after it was made. A play sound
written when client has sound is a sound the world hears only on clients
that play audio, so leave that condition off a sound something in the story
must hear.
Playing and showing
create the primer plunger
aka plunger
a thing, scenery
in the Boiler Shed
A stiff brass plunger on the boiler's flank.
after the player pushing
play sound boiler-thump when client has sound
phrase primer-thumps
end after
| Statement | Effect |
|---|---|
play sound <name> | play the sound once |
play music <name> | start the track; add looping to repeat it |
stop music | stop the track |
play ambient <name> | loop a sound as a bed; in <bed> names a bed other than the default |
stop ambient | stop the default bed; stop ambient in <bed> stops a named one |
show image <name> | show the picture; in <slot> names where the page puts it |
hide image | take the picture down |
transition <kind> | a visual transition the client renders |
clear | clear the client's prose pane |
Every one of these takes the ordinary when <condition> suffix, so a cue
can wait on a state or a client capability:
create the Iron Gates
a room
Wrought-iron gates stand open on one hinge apiece.
after the player entering while the player has the deed
play music dawn-theme when client has music
win fernhill-saved
end after
client has sound, client has music, and client has images are true
when the client running the story can play that kind of media. A cue
without the guard is harmless on a client that cannot honour it — the
guard is for the story that wants to say something different when the
music cannot play.
Ambients follow the player
An ambient is a looping bed the rooms of a region can share. Start it on arrival and stop it on leaving, and the wind follows the player across the grounds and stops at the door:
create the Grounds
a region
after the player entering
play ambient night-wind when client has sound
end after
after the player leaving
stop ambient when client has sound
end after
create the Gravel Drive
a room
in the Grounds
Gravel crunches underfoot.
create the Fountain Court
a room
in the Grounds
A dry fountain stands in the middle of the court.
The Fernhill walkthrough shows all three kinds wired into a complete story and played in the browser build.