mwg API
    Preparing search index...

    Function importTwee

    • Reads a .twee file into a StoryScript.

      Twee was chosen over Twine's <tw-passagedata> HTML export on purpose: it is plain text, so this stays a pure string parser with no DOM - testable under node --test and loadable through mwg/assets like any other text asset.

      Only structure is imported, and that answers the format question the roadmap left open: each passage's text lines become say commands and its [[links]] become one closing ask whose choices jump ([[text]], [[text->target]] and [[target<-text]]) - the last text line doubles as the question, since a choice box needs a prompt and repeating it works. No story-format macro language (Harlowe, SugarCube, Chapbook) is interpreted - body text reaches the stage untouched, and a link carrying a setter throws instead of silently dropping the behaviour the setter described.

      :: Start
      You stand at a crossroads.
      
      [[Take the left path->Left]]
      [[Take the right path->Right]]
      
      :: Left
      The path ends at a wall.
      [[Go back->Start]]
      

      Parameters

      • source: string

      Returns TwineStory

      import { importTwee, StageScript } from '@datamoc/mw_games/two-d';

      declare const tweeSource: string;
      declare const script: StageScript;

      const story = importTwee(tweeSource);
      await script.runStory(story.story, story.start);