import { parseTwee } from '@datamoc/mwg/core';
const story = parseTwee(`:: Start
You reach the gorge.
[[Build a bridge->Build]]
[[Turn back->Home]]
:: Build
The planks hold.
:: Home
You go home.
`);
function show(passage: string): void {
for (const command of story.story[passage]) {
if ('say' in command) console.log(command.say);
else {
console.log(command.ask); //the last text line doubles as the question
for (const choice of command.choices) console.log(' -', choice.text, '->', choice.goto);
}
}
}
show(story.start);
Parses Twee passages (
:: Name, text lines,[[links]]) into aTweeStory: each passage a list ofsaycommands closed by anaskwhen it has links. To play one on a scene, import the source withimportTweefromtwo-d/stage(orrpg), which names that module's own script type.