角色
了解如何在 Pixi’VN 的 ink 脚本中定义、使用和自定义角色,包括将角色关联到对话、名称替换、重命名和情感设置。
阅读本节之前,建议先了解如何在 Pixi’VN 中创建和使用角色。
使用方法
将角色关联到对话
你可以在 ink 中将角色关联到对话。 To do this, you need to use the following syntax:
mc: Hello例如:
=== start ===
mc: Hello, I'm Liam.
-> DONE在对话文本中使用角色名称
你可以在对话中使用角色的名字。 To do this, you need to use the following syntax:
Hello, [mc].例如:
=== start ===
Hello, [mc].
-> DONE要使用此语法,你需要注册一个 文本替换,以便将角色 ID 替换为角色的名字。
模板
所有模板都已经包含这个文本替换。
例如,你可以添加以下文本替换:
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.",
});编辑
你可以在 ink 中编辑角色信息,例如更改角色的名字。 To do this, you need to use the following syntax:
# rename mc Liam例如:
=== start ===
mc: Hello, I'm [mc].
# request input string
mc: My name is:
# rename mc {_input_value_}
mc: My name is [mc]
-> DONE要使用此语法,你需要注册一个 井号命令,用于更改角色的名字。
模板
所有模板都已经包含这个井号命令。
例如,你可以添加以下井号命令:
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(),
]),
},
);角色情感
你可以在 ink 中使用 角色情感。为此,你只需使用一个特殊 ID,它由角色 ID、分隔符 @ 和情感组成:
mc@happy: Hi, I'm Liam. I'm very happy today.例如:
=== start ===
mc@happy: Hi, I'm Liam. I'm very happy today.
-> DONE