| title | Dialog |
|---|---|
| order | 7 |
| description | Show the text players read, as narration, a character's line, an NVL page or centered text, with side images, classes, variables and text effects. |
Dialog is the text your players read. Any text statement that no other action understands is shown as a line of dialog: narration, a line spoken by a character, a line on an NVL page, or centered text. Each line waits for the player to click before the story goes on.
[TOC]
'<text>'
'<who>[:<expression>[:<classes>]] <text>'| Part | Type | Default | What it does |
|---|---|---|---|
<who> |
text | narration | The first word: a character's id, or narrator, nvl or centered. Any other first word is part of the text, and the line is narration. |
:<expression> |
text | the character's default_expression |
Which of the character's expressions to show as a side image next to the text. |
:<classes> |
text | none | CSS classes for this line, separated by ` |
<text> |
text | (required) | What's shown. It can hold HTML, variables and text effects. |
The first word is checked against your characters before anything else, so a character whose id is narrator, nvl or centered takes that word's place.
A line whose first word isn't a character's id is narration: it shows without a name.
'The bell rang, and nobody moved.',narrator makes the narrator explicit, and is left out of the text. Use it when the line starts with a word that is also a character's id or a statement:
'narrator y is the twenty-fifth letter of the alphabet.',To give the narration a name, a color, an NVL page or side images, declare a character with the id _narrator. Narration then uses its properties:
monogatari.characters({
'_narrator': { name: 'Narrator', color: '#cccccc' },
});Start the line with the character's id. Their name shows above the text in their color:
monogatari.assets('scenes', {
'afternoon': 'afternoon.jpg',
});
monogatari.characters({
'y': {
name: 'Yui',
color: '#c28cf0',
directory: 'yui',
sprites: {
'happy': 'happy.png',
},
expressions: {
'smiling': 'smiling.png',
},
},
});
monogatari.script({
'Start': [
'show scene afternoon',
'show character y happy',
'y Hi! My name is Yui.',
'y:smiling It\'s nice to meet you!',
'end',
],
});Put afternoon.jpg in assets/scenes/ and Yui's happy.png and smiling.png in assets/characters/yui/. The first line shows Yui in purple above the text. The second also shows smiling.png as a side image next to the text box.
What a character's declaration does for their lines:
| Property | What it does |
|---|---|
name |
The name shown above the text. It can hold variables: '{{player.name}}'. Without it, no name shows. |
color |
The name's color. Without it, the --character-name-color CSS variable (white). |
expressions |
Side images, by name: { 'happy': 'happy.png' }. Files go in assets/characters/, inside the character's directory if it has one. |
default_expression |
The name of an expression to show when a line doesn't name one. |
nvl |
true shows every line of this character on an NVL page. |
type_animation |
false shows this character's lines at once instead of typing them. |
See Characters for declaring characters, and Characters for their sprites.
While a character speaks, their sprite on screen (if it's showing) gets the focus class, and the text box gets a data-speaking attribute with their id (and data-expression with the expression shown), so you can style either from style/main.css.
Classes after the second colon are added to the text box for that line only, and taken off at the next line:
'y:happy:big|loud I passed the exam!',
'y::thought I hope nobody saw that...',
'centered::chapter-title Chapter 2',Style them in style/main.css:
text-box.thought {
font-style: italic;
}For a centered line, the classes go on the centered-dialog element instead.
nvl lines pile up on a page that covers the screen, instead of replacing each other. A character declared with nvl: true always speaks this way, with their name before their first line in a row:
monogatari.characters({
'y': { name: 'Yui', color: '#c28cf0', nvl: true },
'm': { name: 'Mio', color: '#ff8aa8', nvl: true },
});
monogatari.script({
'Start': [
'show scene afternoon',
'nvl The rain had not stopped for three days.',
'nvl Every afternoon the same grey light fell on the palace.',
'y I keep thinking it has to stop at some point.',
'm Maybe it never will.',
'end',
],
});The page keeps filling until something empties it: Clear starts a new page and stays in NVL, while a line that isn't NVL, or Show Scene, goes back to the normal text box. Side images aren't shown on an NVL page.
centered shows the line in the middle of the screen, without the text box: for time skips, chapter titles and endings.
'centered Three hours later.',The text box hides while the line shows. The next click takes the line away, and the next line brings the text box back.
The centered-dialog element has the text box's colors, white text on a box of the main color, so the line reads over light and dark scenes. To change its look, give it a style of your own in style/main.css:
centered-dialog {
background: rgba(0, 0, 0, 0.6);
color: #ffffff;
padding: 1em 2em;
}{{name}} shows a variable; {{player.name}} reaches into an object:
'y Hi, {{player.name}}!',The value is shown as text: HTML in a variable shows as written, so a name the player typed can't change the page, while HTML you write around it works ('y Hi, <b>{{player.name}}</b>!'). A variable that doesn't exist opens an error dialog while you develop, and the line shows it as written, {{nobody}}. See Variables in statements.
A game that keeps HTML in its own variables on purpose (an icon, a colored word) can show it as HTML again, with this setting in js/options.js:
'AllowHTMLInVariables': true,It covers every place a variable shows: dialog, names, choices, messages, inputs and the credits. Don't turn it on if any variable holds what a player typed, like their name. A _(Key) translation string is another place for a piece of HTML you reuse: translation strings keep their HTML.
The text is typed letter by letter. Markers in the text change the pace and the style while it's typed.
| Marker | What it does |
|---|---|
{pause:1000} |
Stop typing for that many milliseconds. |
{speed:50} |
Change the typing speed by a percentage of the speed at that point: 50 types at half speed, 200 at double speed, 0 as fast as it can. |
'y Hello...{pause:1000} Are you there?',
'y {speed:50}I am... so... tired.',Wrap text in an effect with {effect}text{/effect}:
| Group | Effects |
|---|---|
| Shake | shake, shake-hard, shake-slow, shake-little, shake-horizontal, shake-vertical |
| Wave | wave, wave-slow, wave-fast |
| Reveal | fade, fade-slow, blur, scale, scale-bounce, slide-up, slide-down |
| Glitch | glitch, glitch-hard, glitch-slow |
| Emphasis | bold, italic, big, small, impact |
| Reveal style | redacted, invisible-ink, handwriting, strike, flicker |
| Emotion | angry, scared, happy, sad, mysterious, excited, whisper, shout, dizzy, dreamy, robotic, static |
| Color | rainbow, glow |
'y I\'m {angry}so frustrated{/angry}.{pause:500} {whisper}But I\'ll be okay{/whisper}...',Each letter inside an effect gets a data-effect-<name> attribute that the engine's CSS animates. A marker that isn't in these tables, like {color:red}, shows as written.
Effects show on a typed line and on a line that shows at once (the type animation is off for it, or the player clicks while it's typing and InstantText is true, as in the starter game). {pause}, {speed} and other markers that act while the line types only run when the typing reaches them: a line shown at once skips them, and with InstantText: false a click types the rest of the line very fast and runs them.
The text can hold HTML:
'y The <span class="highlight">important</span> thing is...',These settings go in js/options.js:
| Setting | Engine default | Starter game | What it does |
|---|---|---|---|
TypeAnimation |
true |
true |
Type text letter by letter. With false, every line shows at once, and the Text Speed slider is hidden from the settings screen. |
NarratorTypeAnimation |
true |
true |
Type narration. |
CenteredTypeAnimation |
true |
true |
Type centered lines. |
NVLTypeAnimation |
true |
true |
Type NVL lines. |
InstantText |
false |
true |
What a click during typing does: true shows the whole line at once, false types the rest very fast. |
TypingCursor |
false |
false |
Show a blinking cursor after the last typed letter (see Type Writer). |
A character's type_animation: false turns typing off for their lines. The typing speed is the player's TextSpeed preference: about that many milliseconds per letter, 20 by default, changed with the Text Speed slider (1 to 50) on the settings screen. See Configuration.
Every line shown is added to the dialog log, which players open with Log in the quick menu to read past lines. Going back takes lines out of it. See the dialog log component.
A line waits for the player. A click (or the right arrow key or space bar) while the line is still typing finishes it; the next click goes on.
Going back lands on the line before, typed again. On an NVL page, the last line is taken off the page, and going back past a clear or a scene change brings the previous page back.
| Dialog title | When | What to do |
|---|---|---|
A dialog is being shown while the textbox is hidden |
A line runs while the text box is hidden with Hide Text Box. The line goes into the hidden text box, so the player doesn't see it. | Run 'show textbox' before the line. |
A typo in a statement, a character id or a misspelled keyword isn't reported: the line is shown as narration, starting with the misspelled word. If a line shows up with an id or a statement in front of it, check its first word.
- Clear: empty the text box or start a new NVL page.
- Choices: show options with a line of dialog.
- Characters: show a character's sprite.
- Hide Text Box: hide the text box.
- Text box component, centered dialog component and type writer component: the elements that show the lines.


