Sentence
Sentence is a part of the Character. It is used to construct a dialogue.
Constructing a sentence:
import { Sentence } from 'narraleaf-react';
const character = new Character("character 1");
const sentence = new Sentence([
"Hello, ",
Word.color("world", "#f00") // words can be colored,
], {
character,
});or
const sentence = new Sentence("Hello, world");or
const sentence = new Sentence([
"Hello, ", persis.get("playerName"), "!"
]);
Public Method
constructor
text: SentencePrompt- See SentencePromptconfig?: Partial<SentenceUserConfig>- SentenceUserConfig
copy
Copy the sentence
const sentence = new Sentence("Hello, world");
const sentence2 = sentence.copy();- Returns:
Sentence
getMetadata
Returns runtime-only metadata from the sentence config (from SentenceConfig); undefined when unset. Metadata is not serialized with saves.
const sentence = new Sentence("Hello", {
metadata: { uiHint: "emphasis" },
});
sentence.getMetadata(); // { uiHint: "emphasis" }- Returns:
SentenceMetadata | undefined