Howdy, Stranger!

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

Does anyone know where I can find the specs for building a custom Twine 2.0 story format plugin?

As the title says, I'm having a hard time finding anything resembling an API reference for the story formats, and trying to reverse-engineer from existing ones is not proving to be fruitful. Anyone know where I can find more info other than what each of the existing formats does/doesn't do?

The reason I'm looking is I would like to use the Twine editor to create a story and generate a non-HTML format for consumption by a web service.

Thanks in advance for any help/suggestions/links!

Comments

  • This topic has been asked before but due to the limitations of the forums search feature I am not able to find it.

    note: I am going to use SugarCube 2 as a basis for the following instructions because it is a well documented third-party story format that has to solve the same issues you will need to.

    The problem consists of two parts:

    1. How to get the Twine 2 application to know your new story format exists.

    I would look at the SugarCube 2.x in Twine 2 install instructions which explain where you need to place your new story format. I would also look at the sugarcube-2.6.2-for-twine-2-local.zip file to see the directory structure and files (format.js and icon.svg) that make up a story format.

    2. Constructing your own format.js file.

    If you open SC2's format.js file in a Text Editor you will see that it consists of two main parts:

    a. The code that defines and loads the story format.
    window.storyFormat({
    	"name":"SugarCube 2 (local/offline)",
    	"version":"2.6.2",
    	"description":"... a description... ",
    	"author":"Thomas Michael Edwards",
    	"image":"icon.svg",
    	"url":"http://www.motoslave.net/sugarcube/",
    	"license":"Simplified BSD License",
    	"proofing":false,
    	"source":"...the contents of the HTML web-application template..."
    });
    

    b. the HTML web-application template.

    The contents of the template does not have to be a HTML web-application, it can almost be anything you want as long as it includes specific markup tags which will be replaced by the Twine 2 application with specific data during the Test/Play/Publish to File/View Proofing Copy activities

    Two of the markup tags are:
    {{STORY_NAME}} - The name of your story
    {{STORY_DATA}} - Your story's Passages including Story Javascript and Story Stylesheet.

    I hope the above helps.
  • edited May 2016
    Thanks a lot! I had searched, thought this should really be easy to find...
    This topic has been asked before but due to the limitations of the forums search feature I am not able to find it.

    If nothing else, it seems like it would be a great addition to the Twine wiki since it's apparently asked often enough and is hard to find on the forum...?
  • There's also the storyformatskeleton repo, which you may or may not find helpful.
  • There's also the storyformatskeleton repo, which you may or may not find helpful.
    I believe that is a private repository, so access rights would need to be obtained first.
  • edited May 2016
    greyelf wrote: »
    There's also the storyformatskeleton repo, which you may or may not find helpful.
    I believe that is a private repository, so access rights would need to be obtained first.

    Yup private access only. Just tried myself as I want to know.
    Edit: Just copied the harlow format out of the twine.app package.
Sign In or Register to comment.