inkle / inkle/ink

HTML Framework with Save/Load Functionality

Open
#547 18 comments 3 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.9k
Forks
540
PR merge metrics
No merged PRs in 30d

Description

Forgive me if this is not the place to share utilities, but I've seen others being shared, so I thought maybe it was okay.

One major hurdle that new users have with Ink is that it doesn't offer easy deployment right out of the gate. Compared to Twine or ChoiceScript, Ink dosen't offer saving and loading without additional coding, which only makes it viable for small games. Most writers don't want to be coders, so you lose a large portion of the user base without having this functionality from the start.

Having said all of that, I took the standard exported web page and tweaked it a bit by adding saving, loading, and autosaves. There are 5 save slots currently (more can be added by editing the HTML) and works independently of the autosave. The autosave saves at every choice and autoloads when you load/refresh the page or app. This is for when you accidentally close the tab or application. I was able to make an android app using cordova and everything works as expected.

I also added a function to switch between Ink's normal infinite scrolling method (the one seen in Inky and the standard exported web page) and a page clearing method similar to the one employed by Twine and ChoiceScript. This is done by calling `inkgame.setPageClearing(true)` in JS or the global tag `# pageclearing: true` in Ink to enable the Twine-like paging.

If the global tag `# history` is set to a number greater than 0, a `back` button will be enabled in the page and allow you to return to previous blocks of texts. The amount of "undos" that are available are specified by the value you set. The history is limited to the current session and is not saved.

Anyway, I think this will be really useful to new users, so I wanted share it. Anyone is free to use it (no credit necessary), and if you wanted to incorporate it into the main Ink project that's also okay. I would love it if Ink became as popular as Twine or ChoiceScript.

Here are the files: [ink_project.zip](https://github.com/inkle/ink/files/3802267/ink_project.zip)

To use the project, just export your `story.js` file like normal and overwrite the one in the folder. The global tags `# title` and `# author` are supported, along with `# theme: dark` as in the original.

Extra:
For Windows 10 users, you can use windows powershell in combination with inklecate to have windows watch a directory and automatically recompile the `story.js` file when your ink files are updated. This allows you to use an editor other than Inky without typing the compile command on the command line over and over. You can also use Inky and save your file by just pressing control+S without having to do control+alt+S and then manipulating the save window over and over.

To use, just drop the `watch.ps1` file into the directory with your ink files and inklecate. Right-click on the script and choose `Run with PowerShell`. Closing the powershell window will kill all of its running processes after. Also, the main ink file it chooses to compile is `story.ink` by default. This can be changed easily in the script.

This is the script file: [watch.zip](https://github.com/inkle/ink/files/3748486/watch.zip)

Updates
09/23/2019: Fixed bug preventing paragraph tags (`CLASS`, `IMAGE`, `RESTART` and `CLEAR`) from being read from the Ink story.

10/20/2019: Added directory watch script to ease accessibility.

10/30/2019:
Made paragraph tags case insensitive. This only affects the tag, not the value assigned to it.
Restarting now does a hard reload of the page and removes the autosave to ensure all data is fresh.

11/03/19:
Fixed saving issue with Microsft Edge browser (emulating local storage using cookies).
Fixed scrolling issue with Edge browser.
Added a `back` button to undo choices and return to previous passages. Set `# history` to the amount of undos you would like to allow.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.