Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Compiling an index of passages in reading order for linear story

I think this is something of a tricky one, since it goes a bit against the grain of what Twine is meant to be. I have a project that is mostly linear, but with optional "sidetrips", generally or always only a passage long, that return to the main flow. What I'd like to be able to do is generate a browsable index of all of the passages in the project, in reading order.

The difficulty is that, even though the passages are organized in my source in reading order, the story's passages end up in the storage-area in something very close to random order (at least when you compile with Twee + SugarCube, as I am doing). I am having a hard time coming up with a way to capture the order aside from keeping a manually compiled list of the reading order. Is there a way to generate a list of passages that would capture them in roughly the same order as my source code?

I use a <<continue "next passagename">> macro in every passage to create a button that brings the reader to the next passage, so I could write a routine that would do a brute-force "read-through" of the passages in the store-area to compile the right reading order. And probably that's what I will have to do--but I'm wondering if there might be a gentler way? 

Comments

  • You could patch tiddlywiki.py to preserve the passage order: in addTiddler(), in addition to storing the passages in a dictionary, store the passage names in a list and pass that list to the toHtml() method, which has an "order" argument that is currently unused (or even simpler, use it inside toHtml() when "order" is None). That way, you can force the storage order to be the same as the source order.

    Another option could be to use a simple script to extract all the passage names from the source and put those in a passage by themselves. That could be easier to parse than parsing full passages, although it adds an extra step to the build process (not really an issue if you use a Makefile or script to build already).
  • Either one of mth's suggestion should work.  Strictly speaking, there's no reason that preserving the ordering from the source files shouldn't be the default (not preserving it offers no real benefits, so why not).

    Alternatively, tweego might work for you, it maintains the source to output ordering of the passages by default.
  • Sounds good, thanks to you both. I had no idea about the existence of tweego, I may have to look into that in more detail anyway!
  • TheMadExile wrote:

    Either one of mth's suggestion should work.  Strictly speaking, there's no reason that preserving the ordering from the source files shouldn't be the default (not preserving it offers no real benefits, so why not).

    Indeed, maybe I should just patch tiddlywiki.py to preserve the order and create a pull request to make it the new default.
  • Twee in Git now preserves the passage order. See this commit for details.
Sign In or Register to comment.