simple-visual-novel
    Preparing search index...

    Class Script

    Manages the complete story script with all scenes.

    A Script is the top-level container for a visual novel story. It holds all scenes in order and provides methods to access them by ID or index.

    Scenes are played in the order they are added to the script.

    Script

    const script = new Script();

    const scene1 = new Scene("intro", { background: "title.png" });
    const scene2 = new Scene("chapter1", { background: "forest.png" });

    script.addScene(scene1);
    script.addScene(scene2);

    // Access scenes
    const intro = script.getScene("intro");
    const firstScene = script.getSceneByIndex(0);
    Index

    Constructors

    Accessors

    Methods

    • Adds a scene to the script. Scenes are played in the order they are added.

      Parameters

      • scene: Scene

        The scene to add

      Returns void

      If a scene with the same ID already exists

    • Gets a scene by its ID.

      Parameters

      • id: string

        The scene ID

      Returns Scene | undefined

      The scene, or undefined if not found

    • Gets a scene by its index in the script.

      Parameters

      • index: number

        The scene index

      Returns Scene | undefined

      The scene, or undefined if index is out of bounds

    • Gets the index of a scene by its ID.

      Parameters

      • id: string

        The scene ID

      Returns number

      The scene index, or -1 if not found