0 votes
by (120 points)
I have designed a binary choice based story using Twine and Sugarcube.. I want to distribute (mail HTML files) this story among my friends, so that their response choices get automatically saved on cloud ....

Is it possible to do so ???

1 Answer

0 votes
by (44.7k points)
edited by

There's some information on how to do this with Google Sheets here:

John Stewart: "Twine Game Data to Google Sheets via Javascript version 2"

That said, I had to tinker with the upload code a bit to get it to work.  So you might have to use something more like this:

window.sendData = function () {
		url: "https://script.google.com/macros/s/(your link)/exec",
		method: "POST",
		dataType: "json", 
		data: JSON.stringify(State.temporary.data)
	}).done(function() {
		/* alert("Success!"); */
	}).fail(function() {
		/* alert("Failure."); */

(Replace the URL above with the correct one for your Google Sheet, using the instructions on the page I linked to.)

Hope that helps!  :-)

by (120 points)
Thanks a lot..... But I have developed my game in Sugarcube, but the code is in Harlow..... Can you suggest the necessary changes.... I am entirely new to coding, so is there is any easier way to accomplish this ?????

Thanks a lot.....
by (44.7k points)

There's really not much more to it than the above code.  You just put into your passage something like this:

<<set _data = { Name: $name, Date: _CurDate, Passage: _CurPassage }>>
<<run sendData()>>

where each of the properties (like "Name", "Date", etc...) match the columns in your Google Sheets page, and then the "<<run sendData()>>" line will upload the contents of the _data temporary variable to the Google Sheets page.

The toughest part is really setting up the Google Sheets page to accept the data and getting the correct URL for this to work.