A table rolling language for use in RPG prep, storytelling, or just providing that dash of inspiration.
The complete grammar of RTL is described in the syntax file in the W3C ENBF syntax. You can read RTL Basics for a more user-friendly guide.
Library usage is dependant upon where and how you're using the tool, but for basic node.js applications where files are retrieved from the local disk, the following code will work:
const { RTL, markdownFormatter } = require("rtl-lang");
const { cliErrorHandler, cliFileLoader } = require("rtl-lang/dist/cli");
const rtl = new RTL({
errorHandler: cliErrorHandler,
fileLoader: cliFileLoader,
formatter: markdownFormatter
});
// to roll once
rtl.roll("./myTable.rtl").then((result) => {
console.log(result);
});
// to create an object for rolling in the future
const myTable = await rtl.createTableSet("./myTable.rtl");
// generates a list of tables that can be rolled from this object
console.log(myTable.tables.join("\n"));
// rolls the default result
console.log(myTable.roll());
// rolls the named table
console.log(myTable.roll("myTable"));
- Have node.js 18.17.0 or newer installed.
- Install RTL globally with
npm install -g rtl-lang
.- Ensure global npm binaries are in your path
- Run
rtl [yourFile.rtl]
in bash/powershell/cmd/whatever.
rtl - generate random result from table
rtl [OPTION]... [TABLE] [COUNT=5]
Generate COUNT
random results from TABLE
using format specified by option or table, defaulting to markdown.
-a
: Format results as asciidoc
-h
: Format results as html
-m
: Format results as markdown
-p
: Format results as plaintext
-t
: Format results as tiddlywiki
-d
: Provides debug information