dialogue

@motioneffector/dialogue

A lightweight, type-safe branching dialogue system for games and interactive fiction.

npm version license TypeScript

Features

Read the full manual →

Quick Start

import { createDialogueRunner } from '@motioneffector/dialogue'

const dialogue = {
  id: 'greeting',
  startNode: 'start',
  nodes: {
    start: {
      text: 'Hello! How can I help you?',
      choices: [
        { text: 'Tell me more', next: 'about' },
        { text: 'Goodbye', next: 'end' }
      ]
    },
    about: { text: 'I am a dialogue system.', next: 'start' },
    end: { text: 'Farewell!', isEnd: true }
  }
}

const runner = createDialogueRunner()
runner.start(dialogue)
runner.choose(0) // Select first choice

Testing & Validation

License

MIT © motioneffector