@a-morphous/frontispiece-ink-storylets
v1.0.1
Published
Extension to `ink-processor` that enables storylets.
Readme
Ink Storylets
Extension to ink-processor that enables storylets.
Usage
First, run CreateStorylets. By default, the getter and setter will work with inkJS, though you can define custom getter and setters for variables for other ink implementations.
In the engine, once the ink processor is created, register the 'HUB' as a new command. This is the command you use to start your storylet section, and get your storylets.
Note that
HUBmust be in all-caps to work with Recital
const storylets = CreateStorylets()
InkHookStateController.registerCommand('HUB', storylets.Hub)
The hub will cause you, when you select choices, to get a list of choices from available storylets. When you click on one of those choices, the engine should make sure to use the custom followStoryletChoice function:
<button onClick={() => {
const anyChoice = props.choice as VisualStoryletChoice
if (anyChoice.id === 'storylet-choice') {
followVisualStoryletChoice(inkState._engine, anyChoice)
} else {
inkState.makeChoice(props.choice.index)
}
}}>{props.choice.text}</button>Writing stories with storylets
The code here assumes you're using Recital, in which case storylet syntax can be found here.
All storylet sections are top-level knots, and the storylets are the stitches inside of the knot, with tags attached to the stitch to produce the logic.
