Characters
Learn how to define, use, and customize characters in Pixi’VN ink scripts, including dialogue association, name replacement, renaming, and emotions.
Before to read this section, it is recommended to read how to create and use characters in Pixi’VN.
Use
Associate a character with a dialogue
You can associate a character with a dialogue in ink. To do this, you need to use the following syntax:
mc: HelloFor example:
=== start ===
mc: Hello, I'm Liam.
-> DONEUse character name in dialogues text
You can use the character name in dialogues. To do this, you need to use the following syntax:
Hello, [mc].For example:
=== start ===
Hello, [mc].
-> DONETo use this syntax, you need to register a text replace that replaces the character id with the character's name.
Templates
In all templates, this text replace is already included.
For example, you can add the following text replace:
import { TextReplaces } from "@drincs/pixi-vn-ink";
import { RegisteredCharacters } from "@drincs/pixi-vn/characters";
TextReplaces.add((key) => RegisteredCharacters.get(key)?.name, {
name: "character name",
validation: "characterId",
type: "after-translation",
i18nInterpolation: true,
description:
"Replaces a character ID with the character's name in the game.",
});Edit
You can edit a character's information in ink, for example, you can change the character's name. To do this, you need to use the following syntax:
# rename mc LiamFor example:
=== start ===
mc: Hello, I'm [mc].
# request input string
mc: My name is:
# rename mc {_input_value_}
mc: My name is [mc]
-> DONETo use this syntax, you need to register a hashtag command that renames the character.
Templates
In all templates, this hashtag command is already included.
For example, you can add the following hashtag command:
import { characterIdsEnum } from "@/pixi-vn.keys.gen";
import { HashtagCommands } from "@drincs/pixi-vn-ink";
import { RegisteredCharacters } from "@drincs/pixi-vn/characters";
import zod from "zod";
HashtagCommands.add(
async (script) => {
const character = RegisteredCharacters.get(script[1]);
if (character) {
character.name = script[2];
}
return true;
},
{
name: "character rename",
description: `Renames a character in the game.
\`\`\`ink
# rename <characterId> <newName>
\`\`\``,
validation: zod.tuple([
zod.literal("rename"),
zod.enum(characterIdsEnum),
zod.string(),
]),
},
);Character emotions
You can use the character emotions in ink. To do this you just need to use a special ID composed of the character id, the @ separator, and the emotion:
mc@happy: Hi, I'm Liam. I'm very happy today.For example:
=== start ===
mc@happy: Hi, I'm Liam. I'm very happy today.
-> DONE