TwineGang is a server and client for cross-browser, cross-device Twine game control and synchronization. When two or more Twine games are synchronized, taking a link to a new passage in any of them will advance all other games to the same place. Plays nice with Heroku app hosting.
Originally developed for use in the Global Game Jam 2014 entry, "Get a Clue" (play, source).
npm install
to install dependencies.index.html
in this project's root next to tg_server.js
.node tg_server.js
.http://localhost:3000
. Your story should appear. If you've already followed the steps
below to integrate your story with TwineGang, your story will request a room from the server
in the background, and print a link to join that room to the browser's javascript console
(in the form http://localhost:3000/?room_name=867-5309
).Make sure your exported Twine HTML file loads the libraries TwineGang needs (after jQuery):
<script type="text/javascript" src="https://github.com/mildmojo/twine-gang/raw/master/socket.io/socket.io.js"></script>
<script type="text/javascript" src="https://github.com/mildmojo/twine-gang/raw/master/client/microevent.js"></script>
<script type="text/javascript" src="https://github.com/mildmojo/twine-gang/raw/master/client/tg_client.js"></script>
If you add more scripts and assets to the assets/
directory, the TwineGang web server will serve those files at /assets/<file>
.
<script type="text/javascript" src="https://github.com/mildmojo/twine-gang/raw/master/client/twine_bindings.js"></script>
script
, and paste the contents of story_bindings/twine-v1-script-passage.js
.NOTE: Twine 2 has several "story formats", and not all of them provide scripting hooks, so not all of them can be used with TwineGang. I recommend Sugarcube.
story_bindings
folder (e.g. twine-v2-sugarcube-story-javascript.js
).If there isn't a binding for the story format you use, and you'd like to write one, please feel free to send a pull request!
When each passage is rendered, the integration code described above will tell the server. The server will tel all the clients in the same "room" on the server to visit that passage.
You may attach your own event handlers to TwineGang events with TwineGang.bind
:
TwineGang.bind('clientCount', function(count) {
$('#player-count').text(count);
});
See tg_client.js for available events.
heroku auth:login
heroku apps:create <appname>
heroku git:clone <appname> && cd <appname>
heroku labs:enable websockets
git add index.html && git commit -m 'Adds my story.'
git push heroku master
http://<appname>.herokuapp.com
.TBD
Thanks to Jerome Etienne for the MicroEvent library.