Blog/Interactive Fiction with Twine
Last week I made my first interactive fiction game for a week-long game jam. I'll describe my haphazard search for my final workflow: choosing Twine, its story format, publishing on Itch and eventually transitioning to authoring with the Twee text format.
Interactive Fiction Tooling Landscape Survey
As I was keen on taking a sabbatical from any kind of coding in the break I had before starting my new job, I was looking for a tool that would let me focus on writing prose and it'll do all the other bits and pieces like integrating images and audio seamlessly.
First step: fire up the ol' search engine and work out what's the best tool for the job by making a pros and cons matrix. Just kidding! At this point, the only two interactive fiction tools I had heard of were Ren'Py and Twine, so I was heavily biasing toward one of those.
I looked at Twine first; it let me play around with it on the browser without signing up and the UI was decent.
I then had a cursory scan of the documentation on how to do the rudiments, i.e. linking passages together, how to prompt the user for input (e.g. their name), store it somewhere and print it out later, all of which seemed well designed and documented. Twine it was, then!
Prototyping with orgmode
It became quickly clear that however nice the Twine GUI was, I wasn't going to actually use it to write the prose, since I wanted to flit between passages and eyeball them quickly. I decided to do the bulk of the writing in a text editor and paste it in later.
Emacs worked well since its orgmode format allowed me write the prose, sketch out the flow (with graphviz and embedded codeblock evaluation) and maintain a list of placeholder proper nouns all in the same place.
Then, I planned to paste it section-by-section into the Twine program when finished, hit the 'Publish to file' button and then upload the ZIP onto Itch.
Getting a Twine onto Itch
While all that was going on, I did some due diligence to make sure that I could actually get this thing uploaded onto Itch with all its features working, namely the audio and interactivity.
While testing locally, I found that the audio wouldn't start immediately. After skirting around the rabbit hole that is the getting around the Chrome autoplay policy that prevented audio from auto-playing without user interaction, I realised that it was actually a non-issue when publishing on Itch, since there was a button that said 'Run game' that needed to be pressed on Itch which counted as an interaction.
The Twine program publishes the story into a bundled HTML file; to get it working on Itch, all that needed to be done was to rename it to
index.html and put it in a ZIP file along with any images or music. The only other minor issue on Itch was that the embedded
iframe element the Twine program sits in didn't have the scrollbar appear for longer passages, so I added some CSS to make sure it was always showing.
As an aside, there are two story main formats to use with Twine, each with different markup and scripting capabilities: Harlowe and Sugarcube, with Harlowe being the default and the one I ultimately stuck with. I did try SugarCube as it had an audio macro one-liner to get the background ambient music playing, but when uploading it onto Itch, I ran into a
After dumping the contents of the prose into the Twine program, I realised that iterating on playtesting and any subsequent proofing was going to be fiddly; I still wanted the prose in source control but it was a pain making changes in the document and then threading (har har) it through to Twine to be published.
Another Google search later I came across the twee text format: stories authored this way can be converted into Twine programs with a command line tool. After converting my prose this format with a few hacky regexes, I tried the first Twee conversion tool from the official GitHub repository, which didn't work (to be fair it hadn't been updated in 3 years). However, a newer one called tweego worked out of the box so I used that to finish off the remaining playtest and proofing iterations.
Here is an excerpt of the game with script and stylesheet passages included that will compile with tweego and work on Itch.
Overall, I thought the final workflow with Twee worked well; if I decide to do more graphics I might look into Ren'Py (you can do kick-ass interactive graphic novels with it e.g. King of the Culdesac). There were also a couple of other tools out there I came across like Quest, but I'd probably stick with Twine for straight interactive fiction; the community is active (there's a Twine Discord and subreddit) and people had put in thought about how to work with bigger projects as well.
I had a lot of fun writing in second person point of view, and am reasonably happy with the result too (although the writing quality is decidedly NanWriMo level). One learning from playtesting is that even if you don't present the reader with a choice, it's still nice to break apart a longer passage into shorter linear passages to convey progress.
Finally, I can't help but sign off with a sweet Campbell quote:
"The cave you fear to enter holds the treasure you seek."