Writing choice-based conversation for Inform in Twine

I’m not sure this is the right board; not a question but a sort of low-key announcement, specifically Inform7 related.

I’ve been using AW Freyr’s excellent Hybrid Choices extension to write choice-based conversation for an otherwise parser-based piece. It’s a great extension, but writing conversation trees in Inform prose isn’t totally pleasant: keeping track of where you are without any sort of graphic aid, and filling in the inevitable but tedious boilerplate.

It occurred to me, as it has to others, that Twine is a slick system for writing and prototyping branching narrative, but of course it doesn’t produce Inform code. You can always cut and paste, but it’s a bit of a pain, not least because Twine and Hybrid Choices have the opposite idea of where “choices” should come from (Twine makes them link forward, Hybrid Choices makes them link back, which is a very cunning idea though not instantly intuitive).

Anyway, long-story short, I wrote for my own purposes a python script that takes a Twine story file, converts the links and so forth, and turns it into code that can be cut and pasted into Inform. It’s not a Twine translator (it doesn’t attempt to handle macros or anything like that; it doesn’t even handle markdown though I suppose it wouldn’t be hard to add that; it does convert " to ', and add paragraph breaks). Just a tool to take a prototype and turn it into a first stab at some code, which can then be polished in Inform itself.

In case it’s any use to anyone, I’ve put a copy at https://github.com/PaulStanley/twineconverter. Beware: I’m absolutely NOT a python programmer and I’m sure a real one will wince, but it seems to be working, though I’m sure there are problems I haven’t caught yet. It allows what Hybrid Choices calls “flipping” (using a special link [[@flips->page]]) and one-off (using @one-off) and dead-end (using @dead-end)) branches, though none of those can be accurately previewed in Twine. It can (I think!) cope with the case where you have two twine links with different choice descriptions leading to a single page.

Thanks! This seems very nice.

Oh excellent! This seems like a wonderful tool to have!

I just realized that twine authors that don’t use a lot of substitutions could use this to create screen-reader friendly versions of their games, or even ones that work with Alexa using the inform/Alexa tools. It’s a great move for accessibility.

I think for that I’d need to think more about how to deal (differently) with links that are embedded in the text. If you’re just prototyping for Inform, you naturally put the links at the end, and all we need to do is extract them, turn them into choice-text, handle them, and delete them from the text. You don’t want them in both places because Hybrid Choices takes its choice descriptions from the available choices, and they’d get unnecessarily repeated.

If you wanted to convert a Twine which embedded links in the text, I think you’d need to extract them and then leave their text in the displayed page and /also/ attach it as a choice description for the target page. That’s easy enough to do, but you’d need to find some way of telling the conversion script what to do with any link. I suppose one could just adopt the convention that if a link appears on a line of its own with nothing but links or markup after it, it is deleted, and if it appears anywhere else, it appears both there and (separately) as a choice. But I’d need to think about that, since it wasn’t the use case I had in mind, though it surely would be a good one.

The other issue is logic. As soon as you start trying to translate logic, variables, and so forth, you are in for a world of trouble. For my purposes, I assumed I would simply deal with this in Inform, and any limited logic in text could be embedded in say phrases, so I haven’t attempted to translate Harlow’s programmatic aspects. But I suppose that if at least the text and the most basic logic can be translated, the rest would be approachable.

This sounds absolutely brilliant. I just wish I was a snake wrangler!

This reminds me a bit of how there was a Threaded Conversation extension that could be used in debug where the author could play the game, and if they tried a conversation gambit that wasn’t programmed, it would ask some questions and for some response text, and then when the game quit it showed exact Inform code to copy and paste to implement that conversational thread.

Hybrid Choices is so good that it probably warrants an actual easy creation tool; similar to how Trizbort lets you make a map graphically, and will spit out Inform 7 code that implements it.