Sentence
台詞のテキストとWordを構成する`Sentence`クラス。複製と実行時メタデータを扱う
SentenceはCharacterの一部です。対話を構築するために使用します。
Sentenceを構築する:
import { Sentence } from 'narraleaf-react';
const character = new Character("character 1");
const sentence = new Sentence([
"こんにちは、",
Word.color("世界", "#f00") // wordに色を付けることもできる,
], {
character,
});または
const sentence = new Sentence("こんにちは、世界");または
const sentence = new Sentence([
"こんにちは、", persis.get("playerName"), "!"
]);
パブリックメソッド
constructor
text: SentencePrompt- SentencePromptを参照config?: Partial<SentenceUserConfig>- SentenceUserConfig
copy
Sentenceを複製します。
const sentence = new Sentence("こんにちは、世界");
const sentence2 = sentence.copy();- 戻り値:
Sentence
getMetadata
Sentenceの設定(SentenceConfigを参照)から、実行時のみのmetadataを返します。未設定の場合はundefinedです。メタデータはセーブデータにはシリアライズされません。
const sentence = new Sentence("こんにちは", {
metadata: { uiHint: "emphasis" },
});
sentence.getMetadata(); // { uiHint: "emphasis" }- 戻り値:
SentenceMetadata | undefined