import { parseDialogueText, EventRunner, GameState } from '@datamoc/mwg/rpg';
declare const game: GameState;
const runner = new EventRunner({
game,
present: async (request) => {
console.log(request.speaker ? `${request.speaker}: ${request.text}` : request.text);
},
});
const commands = parseDialogueText(`
@alice Hello.
@bob Hi!
- How are you?
- Fine, and you?
`);
await runner.run(commands);
A terse, line-based text format for straight (non-branching) dialogue - the format a text-only RPG (
coreplusrpg, no renderer at all) can use for its ownEventCommandscripts without depending ontwo-dfor anything.two-d/stagehas its own wrapper around the same parsing engine (core.parseDialogueLines) targetingStageCommandinstead - declared separately for the same reasonEventChoiceis declared separately fromtwo-d/ui'sChoice: a Pixi-based visual novel that never touchesrpg's map events should not have to pull the whole module in just to parse dialogue text, and a text-only RPG should not have to pull in Pixi either. The actual@id/-parsing logic lives once incore.parseDialogueLines, not copied between the two - only the final command shape (speakerhere,asintwo-d/stage) differs.Three kinds of line:
@id textnames who is speaking and saystext;@idalone (no text) just registers the speaker, without saying anything yet.- textcontinues the two-speaker exchange the first two@idlines opened, alternating speaker on every line: the first-after the two openers goes to whichever of them did not speak last, and so on.The
-shorthand is deliberately capped at two speakers: it exists for the two-character back-and-forth, not as a guess at which of three or more people talks next. A third distinct@idanywhere in the source is a parse error rather than a silent guess; a scene with more than two speakers writes@idon every line instead, same as it does today.Lines reach
EventCommand.sayas plain, untranslated text - a game's own translation step decides how that text reaches a player, the same seam MWL's own_("...")-marked strings use (the source text doubles as the catalog key).extractDialogueCatalogbuilds that catalog the same way MWL'sextractCatalogdoes, for a game that wants a translator-ready file to start from.