Characters and Expressions
The path isn’t empty after all: Yui, who was in the drawing class too, is still there. On this page you define two characters, make Yui talk, and change her expression.
Define the characters
A character is someone who speaks in your story. You describe each one once, in js/script.js, and from then on the script calls them by a short id.
The starter game already has one character, Yui, with the id y. Find this part of js/script.js, right above the script:
// Define the Characters
monogatari.characters({
'y': {
name: 'Yui',
color: '#5bcaff',
},
});Replace it with this, which gives Yui her pictures and adds a second character, Mio:
// Define the Characters
monogatari.characters({
'y': {
name: 'Yui',
color: '#c28cf0',
directory: 'yui',
sprites: {
happy: 'happy.png',
smiling: 'smiling.png',
worried: 'worried.png',
angry: 'angry.png',
},
},
'm': {
name: 'Mio',
color: '#ff8aa8',
directory: 'mio',
sprites: {
happy: 'happy.png',
smiling: 'smiling.png',
worried: 'worried.png',
angry: 'angry.png',
},
},
});What each part means, for Yui:
| Part | What it does |
|---|---|
'y' |
Her id, the short name the script uses. Keep ids short, since you’ll type them on every line she says. |
name: 'Yui' |
The name the player sees above her lines. |
color: '#c28cf0' |
The color of that name, as a color code like the one for the background. |
directory: 'yui' |
The folder her pictures are in, inside assets/characters/. |
sprites |
Her pictures, each with a name. happy: 'happy.png' means: the sprite called happy is the file assets/characters/yui/happy.png. |
A sprite is a picture of a character that stands in front of the background. A visual novel usually has several of the same character, one per expression: here, happy, smiling, worried and angry. Mio’s are the same, in her own folder, assets/characters/mio/.
Make Yui talk
Change the script, between 'Someone left a sketchbook…' and 'end':
monogatari.script({
'Start': [
'show scene #2b2340',
'The bell rings at the end of the drawing class.',
'show scene afternoon with fadeIn',
'Everyone hurries off, and soon the path to the Palacio de Bellas Artes is quiet.',
'Someone left a sketchbook on the low wall by the path.',
'show character y happy with fadeIn',
"y Oh, you're still here too?",
'show character y worried',
'y Hey, look. Someone forgot their sketchbook.',
'end',
],
});Save, reload and click through. After the narration, Yui fades in, in the middle of the screen. Her name shows above her lines in purple, and when she notices the sketchbook, her expression changes.

The new statements:
'show character y happy with fadeIn'puts the spritehappyof the characteryon screen, with the same fade as the background."y Oh, you're still here too?"is a line of dialog: a character’s id, a space, then what they say. Without an id in front, the line would be narration.'show character y worried'changes her sprite. She’s already on screen, so the new picture replaces the old one.
WARNING
"y Oh, you're still here too?" is between double quotes because the line has an apostrophe in it. Between single quotes, the apostrophe in you’re would end the statement early, and the game wouldn’t start. When a line has an apostrophe, put it between double quotes, or use a curly apostrophe, ’, which doesn’t count as a quote.
Place characters on the left and right
A character without a position stands in the middle. To place one, add at left or at right:
'show character m worried at left with fadeIn',You’ll use this on the next page, when Mio arrives. Yui and Mio are drawn turned a little to one side, Yui toward the left of the screen and Mio toward the right, so the tutorial puts Mio on the left and Yui on the right: that way they face each other, and look into the scene rather than out of it. To take a character off the screen, use 'hide character y'. A new background (show scene) clears every character from the screen too.
Side images: a small picture next to the text
Besides sprites, a character can have side images: small pictures, usually of the face, that the text box shows next to their line. They go in the character’s expressions, and a line asks for one after a colon: 'y:happy I found it!'. The tutorial’s characters don’t use them. Characters explains how.
Next
Choices and endings: let the player decide what to do with the sketchbook.