@clyde-lang/interpreter
v4.1.1
Published
Interpreter for Clyde dialogue language
Downloads
9
Readme
Clyde Interpreter
Interpreter library for Clyde dialogue language.
import { parse } from '@clyde-lang/parser';
import { Interpreter } from '@clyde-lang/interpreter';
const content = parse(`
Hagrid: Yer a wizard, Harry!
Harry: I'm a what?
* Hagrid: A wizard, Harry!
* Hagrid: Yer a wizard!
`);
const dialogue = Interpreter(content);
dialogue.getContent()
//respone: { type: 'line', text: 'Yer a wizard, Harry!', speaker: 'Hagrid }
dialogue.getContent()
// response:
// {
// type: 'options',
// name: "I'm a what?",
// speaker: 'Harry',
// options: [
// { label: 'A wizard, Harry!' },
// { label: 'Yer a wizard!' }
// ]
// }
dialogue.choose(1)
dialogue.getContent()
// response: { type: 'line', text: 'Yer a wizard', speaker: 'Hagrid }
Instalation
npm install @clyde-lang/interpreter
# or
yarn add @clyde-lang/interpreter