Documentation
Sentence

Sentence

⚠️

This page is under construction.

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(character, [
    "Hello, ",
    new Word("world", {color: "#f00"}), // Some words can be colored
]);

or

const sentence = new Sentence(character, "Hello, world");

or

const sentence = new Sentence(character, [
    ({storable}) => `Hello, ${storable.getNamespace("game").get("playerName")}`
]);

Public Method

constructor

  • character: Character | null - If null, then it is a narrator. Narrator do not show any name in the dialogue box.
  • content: SentencePrompt - See SentencePrompt
  • config?: Partial<SentenceConfig> - SentenceConfig

copy

Copy the sentence

const sentence = new Sentence(character, "Hello, world");
const sentence2 = sentence.copy();
  • Returns: Sentence