A library for managing progress through a nonlinear story, complete with a visual story editor for the writer. First made as a rebuilt backend for my game Keeper of the Labyrinth.

Easily manage multiple options in the editor view.

A clean reader view shows what the reader will see.
- Purpose-built visual editor for traversing a nonlinear story.
- Allows the writer to edit story node text and options / links between nodes on the fly.
- Provides a fully-functional editor mode and a bare-bones reader mode.
- Save and load stories from a portable JSON format.
- Story Renderer class capable of reading JSON story files can be easily imported to other HTML-based projects and built on top of as a back-end.
To use the visual editor,
- Use
tscto compile the project directory. - Make sure
mainFileinmain.jsis set tofull-editor.html. - The editor doesn't have a frontpage yet, so to select which story to edit or to make a new one, enter the filename and so forth into
full-editor-application.tsas directed in the first block after the import statements. - Calling
npm startwill run the application throughelectron-forge. - You can also serve
full-editor.htmlonto your own localhost node.js server if you like. (It has to be on a node server; it won't work to simply open in browser because the application will lack read/write permissions.) - Go write a cool nonlinear story and please let me know if this app worked for you or if you notice any bugs!
To use the renderer in your own project,
- Copy the
scriptsdirectory somewhere into your project. - Make sure you have a
story_datafolder in your project's root directory, and yourstoryname.jsonfile is in it. - In a script tag or file linked to your project HTML document, import
prepareStoryInstanceandStoryRenderer. - Use
prepareStoryInstanceto read your story from disc, and pass that story to a newStoryRendererinstance. An example of this can be seen inrenderer-only-application.ts - The
StoryRendererwill automatically render story content and options into divs with the idsstory-textandstory-options. Make sure these exist somewhere in your HTML structure and you're golden! - Let me know what project you're using my little app for, because I'd love to hear all about it!! :) Also, please credit me if you publish / distribute your work in any way (it's just good etiquette).
- A frontpage for the application with a menu for loading in stories and selecting editor/reader mode and dark/light mode settings (would allow it to be packaged into an executable, making it easier to run and use).
- A menu for setting "conditional story options" only shown to the reader dependent on writer-defined logic. Currently functional but waiting on front-end implementation.
- Reader state tracking and an attached event system for incrementing scores, printing images, and other functionality to be called when a reader traverses particular nodes.
- An autosave system that clears out older autosaves after a while; currently they just stack up in `story_data` endlessly.
The contents of this repository are published under a Creative Commons Attribution 4.0 International License. In short:
You are free to:
Share — copy and redistribute the material in any medium or format.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.