Javascript procedural text generator to make stories, bullshit generators and other pipotrons.
📦 Getting Started
npm install random-story
usage
; const rs = ;rs;rs;rs;rs;rs
API
.add({domain: token, label: label, [ weight=1 ], [ condition ], [ effect ])
Add a new alternative for the specified token. condition
can be a function evaluated with context. If condition return false
for current context, the alternative is disabled. effect
if a function applied to the context that allow you modify it and control sub-token generation according to the new context. vars
object in context are resolved with this values. weight
is the appearance probablity. Default value is 1. Weight
can also be a function that receive the context.
.resolve([ start_label="<start>" ], [ initial context object ])
generate a new result by resolving reccursivelly all tokens.