Giter Club home page Giter Club logo

twine-to-json-to-godot's Introduction

Twine-to-JSON-to-Godot

A story format for converting a Twine 2 story to JSON with special support for Harlowe 3.x.

Twine-to-JSON is inspired by Twison, which in turn was inspired by Entweedle.

Setup

From the Twine 2 homescreen, select Formats and then Add a New Format. At the prompt, paste in one of the addresses below:

For vanilla Twine-to-JSON (without special support for Harlowe 3.x), use this address:

https://erraticunicorn.com/twine-to-json-to-godot/dist/twine.js

Export

Once you've installed format, enter your story and choose Change Story Format. Select the new format and return to your story. Selecting Play will export a JSON file.

From within your story, set the story format to Twison. Choosing "Play" will now give you a JSON file.

Example Output

{
	"uuid": "854562F1-DF88-47FC-92FE-033847090CD2",
	"name": "JockIntroConversation",
	"creator": "Twine",
	"creatorVersion": "2.7.1",
	"schemaName": "Twine to JSON",
	"schemaVersion": "0.0.7",
	"createdAtMs": 1699871852656,
	"passages": {
	  "JockIntro": {
		"title": "JockIntro",
		"tags": "",
		"id": "1",
		"text": "{{name}}Jock{{/name}}\n\nYou coming to the game tonight, brah?\n\n[[Yes|Nice]]\n[[No|End]]",
		"links": [
		  {
			"text": "Yes",
			"next": "Nice",
			"original": "[[Yes|Nice]]"
		  },
		  {
			"text": "No",
			"next": "End",
			"original": "[[No|End]]"
		  }
		],
		"name": "Jock",
		"cleanText": "You coming to the game tonight, brah?"
	  },
	  "Nice": {
		"title": "Nice",
		"tags": "",
		"id": "3",
		"text": "{{name}}Jock{{/name}}\nNiiiiiice",
		"links": [],
		"name": "Jock",
		"cleanText": "Niiiiiice"
	  }
	}
  }

Why use Twine-to-JSON instead of Twison (et al)?

You should probably use Twison. Twine-to-JSON currently has an unstable API and is less well tested. However, if Twison isn't working for you, you may have better luck with Twine-to-JSON. This project uses a more reliable method of detecting links and won't be fooled by embeded json arrays. It also detects some features specific to Harlowe.

Contributing

Please do.

Development

If you want to hack on the package itself:

  1. Clone this repo and run npm install to install dependencies.
  2. Make your changes to the unminified code in the src folder
  3. Run npm run build to compile your source into a format.js file that Twine 2 can understand. It'll be placed in the dist folder. Alternatively, you can run npm run watch to watch the src directory for changes and auto-recompile every time you save.

Testing your changes locally

Running npm start will start the watch.js auto-compile behavior, and also start a local web server that serves the compiled format.js file. By default, this will be available at http://localhost:3000/format.js. Add that URL as a story format to your copy of Twine 2; every time you save a source file and then re-generate the "Play" view of your story in Twine, it should use the latest version of your code.

This is easier to do with the browser-based version of Twine 2 than with the downloadable copy, as you can just refresh your output page and it'll use the latest version of Twison.

twine-to-json-to-godot's People

Contributors

jtschoonhoven avatar erraticunicorn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.