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
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.
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.
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...?
Yup private access only. Just tried myself as I want to know.
Edit: Just copied the harlow format out of the twine.app package.