branching-dialogue
A stateless API for modeling branching dialogue in role-playing games
Background / Initial Motivation
The initial motivation for this library was to power branching dialogue with npc's in a browser game.
To Install
$ npm install --save branching-dialogue
Usage
Conversations are directed graphs are stored as JSON
}
// The example convo.json file from abovevar convo = var branchingDialogue = // We start at dialogue id #2var startText = branchingDialogue // We choose the second response, "Not so good :("var nextText = branchingDialogue// We choose the first response, "Nah, I'm alright thank you"var nextText = branchingDialogue // This gets executed based on the above repliesif !nextTextaction console // Alright, well feel better. // This does not get executedif nextTextaction === 'go-to-dinner' // Your code might send your player to the dinner venue
TODO:
- Implement the module
- Figure out API for conditional start / responses
API
branchingDialogue.get(convo, dialogueId)
-> Object
convo
Required
Type: object
A JSON representation of the conversation.
dialogueId
Required
Type: Number
|| String
The id of the part of the conversation that you are retrieving
See Also
// TODO: Link to the module for parsing the conditional response DSL
License
MIT