A character is someone who speaks or appears in your story. You register each one under a short identifier, and the script uses it: y Hello. is a line Yui says, show character y happy shows her. Characters shows how to write them into a story; this page lists the methods and the properties.

characters()

Reads every character, or registers several.

characters(object?: object | null): object

With an object, it merges it into the characters: a new identifier adds a character, an existing one gets the properties you give merged into its own. It returns every character, by identifier, either way.

The starter game’s js/script.js registers one:

monogatari.characters({
  'y': {
    name: 'Yui',
    color: '#5bcaff',
    sprites: {
      normal: 'yui-normal.png',
    },
  },
});

character()

Reads one character, or registers or changes one.

character(id: string): object | undefined
character(id: string, properties: object): void
Form What it does
character('y') Returns the character, or undefined when there is no such identifier.
character('y', { … }) Merges the properties into the character, or registers it if it’s new. Returns nothing.
monogatari.character('y', { color: '#ff7f50' });

Yui’s name shows in the new color from her next line on.

The properties of a character

Property Type What it does
name string The name the text box shows over the character’s lines. It can hold variables ('{{player.name}}') and interface strings ('_(YuiName)', for a key your game added).
color string The color of the name: any CSS color.
directory string A folder inside assets/characters where this character’s pictures are.
sprites object The pictures show character puts on the scene, by name: { happy: 'happy.png' } for show character y happy.
expressions object The small pictures the text box shows next to a line, by name: { happy: 'face-happy.png' } for the line y:happy I'm glad..
default_expression string The expression shown with every line that names none: a name from expressions, or a file.
type_animation boolean false shows this character’s lines at once, without typing them, while the other characters’ lines still type.
nvl boolean true shows this character’s lines in NVL mode: the text box fills the screen and keeps the earlier lines.
layers string[] The names of the layers the character is drawn with, for character layers.
layer_assets object The pictures of each layer: { hair: { long: 'hair-long.png' } }.

The file names are relative to assets/characters, plus directory when the character has one. Character layers (layers, layer_assets and their statements) are an experimental feature: they need the ExperimentalFeatures setting on. Character Layers explains them.

Names from Monogatari v1

Characters written for Monogatari v1.4.1 still work: when the engine reads a character with character(), it turns the old names into the new ones.

v1 name Becomes
Name name
Color color
Directory directory
Images sprites
Side expressions
Face default_expression
TypeAnimation type_animation

characters() returns a character as it was registered, with the old names, until something has read it with character(). Upgrading from v1.4.1 has the rest of the changes.