Skip to content

Dialogue ​

Lines said by speakers, with talking portraits, a typewriter, lines that wait for the player, choices that branch the story, title cards, and subtitles you can export for translation.

Quick start ​

ts
// in the view
cinematics: { speakers: { 'td.giant': { name: 'The Giant', portrait: { type: 'giant' } } } }

// in a cinematic
await cut.say('td.giant', 'Who crosses my bridge?') // as long as it takes to read
await cut.say('td.giant', 'Pay, or fight.', { waits: true, holds: true, pace: 40, side: 'right', emotion: 'angry' })

The giant's face talks in the HUD's portrait box; the second line types out and waits for Enter or a click.

Common tasks ​

Say a line in the player's language ​

ts
await cut.say('hero', { key: 'heroAnswer', params: { gold: 50 } }, 3)

A line with a key is said in the words the game has for that message, its text where there are none. See Languages.

Ask the player a choice ​

ts
const answer = await cut.choose(
	[
		{ id: 'fight', label: 'Fight' },
		{ id: 'pay', label: 'Pay him' },
		{ id: 'flee', label: 'Run', when: { param: 'scout' } }
	],
	{ name: 'answer', question: 'The giant waits.', seconds: 10, default: 'pay' }
)

// the rules hear it as a command, the same on every screen
defineSequence({
	id: 'campaign.giant',
	steps: [
		cinematic('campaign.giant', { hold: true }),
		waitFor(cinematicChoice, (world, event) => event.cinematic === 'campaign.giant' && event.choice === 'fight'),
		(world) => attack(world)
	]
})

Keys 1, 2, 3 (or an answer's key), a click, or cut.pick(id) pick. The answer is kept as a param (answer) for later conditions.

Show a face that isn't the selected unit ​

ts
await cut.say('giant', 'Who crosses my bridge?', { portrait: { unit: 'giant', zoom: 1.2 }, emotion: 'angry' })

See Unit portraits for framing and talking clips.

Put up a title card ​

json
{ "at": 0, "for": 4, "ui": "title", "title": "The Long Road", "subtitle": "Chapter one", "style": "chapter", "in": 0.5, "out": 1 }

Styles: title (centred), chapter (a small line over it), lower-third, or yours (registerTitleLook(name, { place, title, subtitle })). TitleCard (mountTitleCard in plain DOM) is the same card for your own screens.

Put your own interface on screen ​

ts
cut.ui.mount(titleCard) // an element, over the picture
cut.ui.mount({ component: (p) => <Title text={String(p.props.text)} /> }, { layer: 'hud' }, { text: 'Chapter One' })
cut.ui.pin(label, 'hero', { height: 1, offset: { y: -8 } }) // over the unit's head, following it
await cut.input.key('KeyE') // a key while the player's hands are off

All of it is taken away when the cinematic ends, is skipped, or a seek passes the clip.

Move the box ​

By default a line shows as a small transmission above the console's left: the portrait, the name, the words, about 420 pixels wide. The box is drawn at the HUD's scale (client.hud.scale()), so its width and place are the HUD's pixels on any screen.

ts
cinematics: { dialog: { position: 'right' } } // or 'bottom', 'top', 'center'
client.setDialogLook({ position: 'bottom', width: 640 })

While a cinematic hides the HUD, a left or right box goes to the foot of the picture, in its middle, inside the bars; lines shown as subtitles stay at the foot of the picture as before.

Use subtitles instead of the box ​

ts
cinematics: { dialog: { subtitles: true } }
client.setDialogLook({ subtitles: true }) // or the player's setting

Editor ​

  1. Select a line on the dialogue lane: the Inspector has its speaker, words, length, waits, side, pace, emotion, voice and Face.
  2. Shift+S opens the script: every line in order, edited as text (Enter adds a line after).
  3. The subtitles button exports SubRip (.srt) or WebVTT (.vtt), or lines to translate as CSV (key,speaker,text) or the game's messages JSON.
  4. Import a translation… takes that CSV or JSON back and says what changed.
  5. Key every line writes a stable key (td.intro.3) into lines that have none.

Reference ​

A dialogue clip ​

FieldWhat
speakera speaker of the view's (GameView.cinematics.speakers)
textthe words
keya message of the game's said in the player's language
forseconds (or as long as it takes to read and type)
waitsstays until the player moves it on (Enter, a click: client.skipLine)
holdsalso stands the clock still once its time is up (true on the lane; scripts' don't)
sideleft, right, center
pacetypewriter, characters a second
voice, emotion, portrait, color
skippablefalse: can't be moved on (a line that waits always can)

The first Enter shows the rest of a line being typed; the next moves on. seconds: Infinity is a line that waits.

The queue (client.dialog, DialogQueue) ​

Every line goes into one queue: a cinematic's and the rules' (talk, world.dialog.say). A line said while another shows waits its turn. During a cinematic its lines come first; a rules' line that was showing goes back to show after. cut.dialog.queue(), cut.dialog.history(), cut.dialog.skipAll(). The queue's members: say, remove, head, queue, history, typed, next, skipAll, onChange. The line hook is heard as a line shows.

The dialog box (DialogLook) ​

Declared (GameView.cinematics.dialog)What
positionleft (the default), right: a compact transmission above the HUD's console, at its left or right edge; bottom (above the console, across as the line's side says), top, center
widthin the HUD's pixels, scaled with it: 420 for left and right, 520 for the rest
portrait, nameshown unless false
DialogLook.portraitIn'hud' (the HUD's portrait box) or 'box'
typewritercharacters a second for lines that don't say
subtitlesthe name and words at the foot of the picture, no box
historylines kept

The box has data-emotion, data-side, data-speaker, data-from for your styles. Your own box: dialog: { component: MyBox } (given DialogProps: line, shown(), next(), look, client), dialog: { mount(element, props) }, a line's ui: { component }, or the HUD part dialog. In code: client.setDialogLook(look) (null for the view's again).

Choices ​

In a def, a dialogue clip asks: { at, choice: 'answer', question, options: [...], seconds, default, then: { fight: 'marker:fight', pay: 'end' } }. It holds the clock until answered, then goes to a marker, the end, or on (continue). Looping back to one marker more than 20 times is stopped. The menu is the HUD part choice: GameView.cinematics.choice (position: center or bottom, width), your component or mount (given ChoiceProps), or hud.widgets.

Portraits (PortraitSpec) ​

An image address, { unit }, { type }, { model }, live or mode: 'still', zoom, and any PortraitLook field over the type's. Drawn on the portraits' stage, a side view of the renderer straight onto the box's canvas. A cinematic that hides the HUD shows them in the dialog box.

The ui lane ​

{ at, for, ui: 'title', layer, on: 'hero', height, offset, anchor, z, props }, with the parts in the entry (ui: { title: { component: TitleCard } }). Layers: screen (over the picture), hud (over everything), world (pinned to a unit or spot). The title card is the client's part title (TITLE_CARD) unless the entry has its own.

Subtitles and translations in code ​

cinematicSubtitles: subtitleCues, toSrt, toVtt, localizationRows, toCsv, toMessages, readTranslation, applyTranslation, keyLines; run('export:vtt'), run('import-translation'), run('key-lines'). A line without a key is known by its place (td.intro.3), which moves as lines are inserted. Not yet: timing lines by the translation's length, a voice per language, and the preview in a chosen language (it uses the first).