TBQ is a tool to run simple text-based adventures in node.js. Currently it has structure based on rooms containing objects that can be interacted with.
Create a data file (e.g. data.json
), you can find format explanations in corresponding file. Then use the engine:
const TBQ = require('tbq');
const game = TBQ.createGame(require('data.json'));
do {
var playerInput = /* Somehow get command entered by player */
var actionResult = game.exec(playerInput);
if (actionResult.text !== null) {
/* Output actionResult.text to player */
} else {
/* Output some help */
}
} while (!actionResult.end)
Each game.exec(playerInput)
call returns { text, end }
object (text
property is null
if command is invalid in given circumstances).
MIT