Class Story

A Twine story.

Hierarchy

  • Story

Constructors

Properties

attributes: Record<string, unknown>

General attributes of the story itself, like name or startnode. These appear on the <tw-storydata> element when published.

javascript: string

The story's custom JavaScript.

passages: Passage[]

Passages in the story.

startPassage?: Passage

The start passage of the story, if one exists. This should always be a member of passages.

stylesheet: string

The story's custom stylesheet.

Methods

  • Merges JavaScript source into this story, adding to any existing.

    Parameters

    • source: string

      Source JavaScript to add

    Returns Story

  • Merges the contents of another story object with this one.

    Parameters

    • story: Story

      Other story to merge with; will not be modified

    Returns Story

  • Merges CSS source into this story, adding to any existing.

    Parameters

    • source: string

      Source CSS to add

    Returns Story

  • Sets the start attribute to a named passage. If the passage with this name doesn't exist, this throws an error.

    Parameters

    • name: string

      Passage name

    Returns Story

  • Returns a Twine 2 HTML fragment for this story. Normally, you'd use a StoryFormat to bind it as a complete HTML page.

    Returns string

  • Creates an instance from HTML source. This converts from Twine 1 attribute names to Twine 2 attribute names where possible. Where a mapping isn't possible, the attributes are set as-is.

    Parameters

    • source: string

      source HTML to use

    • twineVersion: number = 2

      Twine version used to created the HTML--must be either 1 or 2

    • silent: boolean = false

      If true, doesn't issue any console warnings about potential problems

    Returns Story

  • Creates an instance from TWS (or Twine 1) source. This converts from Twine 1 attribute names to Twine 2 attribute names where possible. Where a mapping isn't possible, the attributes are set as-is.

    Parameters

    • buffer: Uint8Array | Int8Array | Uint8ClampedArray

    Returns Story

Generated using TypeDoc