User Defined Compile Formats and template formats

I am trying to find a way to write my TWINE2 based interactive fiction in Scrivener for Windows.
My intentions are that I like to write in Scrivener on my iPad. It gives me a huge freedom to write whenever the muse visits. But for scripting in Javascript and CSS, I like to use Visual Studio Code and for finalizing my stories I really like TWINE2. Everything is shown graphically like a Scrapple map.
I already have looked into command line compilers like Twee2 and others, but they are poorly maintained and makes the exchange between Scrivener and TWINE2 unstable. By doing it my proposed way I keep stability and get an easy import/export in both systems. Petty neat if possible.

Below is shown the source format of TWINE2.
As you can see it is a kind of HTML format where the story is packed into this structure:

<tw-passagedata pid="1" name="Title" tags="start" position="219,85" size="200,100">Story: [[1]] [[2]]</tw-passagedata>

The “pid” does not have to have a number, nor does “name” have to be filled, but I assume it could be a Scrivener page name. “position” can be fixed. The “Story:” is where Scrivener writes a “full page” with codes, brackets, links and much more.

The header could be enclosed in the top of a Scrivener document tree:

<tw-storydata name="Little Story Rev3" startnode="1" creator="Twine" creator-version="2.2.1" ifid="025675AE-55C7-4841-8346-F81057838E01" zoom="1" format="Harlowe" format-version="2.1.0" options="" hidden>

So my questions is twofold:

  1. Can I create an import/export/compile format that conforms to this HTML structure? How?
  2. Can I get Scrivener to show me different “variables” like "[[something]] or “:: Something” in a template? This is wiki formatting that TWINE2 uses to link between different “pages”.

If I can get this import/export/compile format to work I can work between TWINE2 and my iPad Scrivener fluently and gain a huge freedom to write wherever I am.

Any suggestions as to how?
Just to clarify. I do not expect my iPad Scrivener can compile anything. Only my Windows desktop version.

<tw-storydata name="Little Story Rev3" startnode="1" creator="Twine" creator-version="2.2.1" ifid="025675AE-55C7-4841-8346-F81057838E01"
        zoom="1" format="Harlowe" format-version="2.1.0" options="" hidden>
        <style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css">
        /*CSS area*/

        <script role="script" id="twine-user-script" type="text/twine-javascript">
        Here you can have JS

        <tw-passagedata pid="1" name="Untitled Passage" tags="start" position="219,85" size="200,100">Gå genne en dør:
                [[1]] [[2]]</tw-passagedata>
        <tw-passagedata pid="2" name="1" tags="" position="146,417" size="100,100">Der er en lang passage der er meget
                Gå gennem [[passagen -&gt; Passagen]]</tw-passagedata>
        <tw-passagedata pid="3" name="2" tags="" position="552,426" size="100,100">Du står i et åbent rum med masser af
                Gå over [[Broen]]</tw-passagedata>
        <tw-passagedata pid="4" name="Broen" tags="" position="521,691" size="100,100">Der er en ork på broen.Gå til
                [[Passagen]] eller til [[Stranden]] </tw-passagedata>
        <tw-passagedata pid="5" name=" Passagen" tags="" position="67,587" size="100,100">Gå ned i [[Kælderen]] eller
                gå ind i [[Huset]]</tw-passagedata>
        <tw-passagedata pid="6" name="Huset" tags="" position="212,776" size="100,100">Der er en ydredør på bagsiden af
                huset til [[Broen]] Du kan tage den eller du kan gå ned i [[Kælderen]]. Hvad vælger du?</tw-passagedata>
        <tw-passagedata pid="7" name="Kælderen" tags="" position="442,517" size="100,100">Der er mørkt og vådt her i
                kælderen. Der ser ud til at være et mørkt hul i bagvæggen. Det er en slags [[ Passagen]] eller tag
                trappen op i [[Huset]] </tw-passagedata>
        <tw-passagedata pid="8" name="Parken" tags="" position="806,693" size="100,100">Double-click this passage to
                edit it.</tw-passagedata>
        <tw-passagedata pid="9" name="Stranden" tags="" position="769,532" size="100,100">Gå til [[Parken]]
        <tw-passagedata pid="10" name="Passagen" tags="" position="521,841" size="100,100">Double-click this passage to
                edit it.</tw-passagedata>

After I have played around with Scrivener for Windows I now have an acceptable hack.
I still need to know how to make import/export converters - there’s nothing in the manual. Maybe someone can point me in the right direction?

By using compile options and preceding documents and placeholders I now have managed to have the entire HTML structure, but as a TXT file, so I still have to rename the compiled document to HTML. That would be nice to get around.

All TOP HTML I now have in the compiled setup under formatting title. It works brilliantly, but I can’t seem to find anywhere I can append text with some code automatically. Can I hide code in a page/text maybe? I need every text block to be appended with this:


I’d like to have links represented in another format than the default. Instead of this “LINK”, I’d like this “[[LINK]]”. How do I change this formatting?

The final matter is placeholders. How do I add my own placeholders?

I have placed my TWINE2 compile template on my GitHub. Please try it out and comment any good ideas you have. It has not exhausted the above questions but it works.

You find the repository here:

//LarsPM :slight_smile:

While Twee2 is poorly maintained (I’ve had to fix whatever bugs bothered me and rebuild it myself in order to use it effectively), TweeGo is well-maintained. However, it is an idiosyncratic command-line program, and that makes it hard for some users to get going with it.

Nevertheless, I think using Twee processors and the twee format avoid the problem you’re running into with closing your xml tw-passagedata elements, since you never have to close a passage in twee format, just open it.

So I use Scrivener (internal document) links to link between Twine passages all the time when using the latest version of my template, Scree 3. In Scrivener 3 it’s easy to convert Scrivener to wiki-style links using the Markup section of your compile format settings. Under “Internal link prefix and suffix:” just fill in [[ and ]]. I’m not sure whether you can do the same thing or how to do it in Scrivener 1, though. Are you planning to update to Scrivener 3?

Even in Scrivener 3, I haven’t found a way to provide different text linking to the same underlying passage when using Scrivener links (the way you can do Twine or normal HTML). AFAIK, all your Scrivener links to a passage must use the passage name itself. You can, however, just use a regular wiki link in this case as long as the rest of your compile settings will pass the link on to Twine as-is.

Hi mc. I have Scrivener for Windows so I have to wait until version 3 arrives for windows.

My template works somewhat well enough to make some good work and have it import to Twine. I’ll try your suggested precompiler.

Your Scree v3 template - Will it work in Windows version?


Sorry, I didn’t see your question until I did a search today. I think the previous version of my template will work in Scrivener 1 for windows, but there are some special instructions to follow there. Also, TweeGo has changed a bit since then, so even if you’ve moved on to Scrivener 3/Scree 3 [which should work in Windows, but I haven’t tested it], the instructions may need some tweaking.