Hello all!
I'm currently doing a project for an upcoming university showcase and was hoping to make it so that I could collect and save the variable inputted by the player through the prompt macro, so that it would be uploaded and saved to a google sheet and then, a passage later, for that piece of data and the ten of so pieces preceeding it to be displayed so that the player can see some other responses.
However, I've run into a bit a of snag in coding the data upload. I've followed the guide as per John Stewart (http://www.johnastewart.org/coding/twine-game-data-to-google-sheets-via-javascript-version-2/) and followed it word-for-word. I then published the file and ran it on my browser but the upload didn't work.
I would appreciate any ideas as to if it's a version issue or if it's just a problem with my coding.
Current code is this:
//in the javascript section
if (!window.harlowe){
window.harlowe = {"State": State};
}
//in the prompt passage
(set: $word to (prompt: "What is the Castle to you?", "Type here!"))
//in the penultimate passage
<script src="jquery-3.3.1.min.js"></script>
<script>
var sendData = JSON.stringify({
"word": harlowe.State.variables['word']
});
$.ajax({
url:"https://script.google.com/macros/s/AKfycbypqjLgC5tAmJPez9ad4hXwDsBWmfQQYr76GKAGzDKqCi9UBAfk/exec",
method: "POST",
dataType: "json",
data: sendData
}).done(function() {});
</script>
The Google Scripts code was copied directly from John Stewart's blog post so that should all be correct and I've changed the var = SHEET_NAME = "...."; with the part in speech marks changed to match the Google Sheets title. The Google Sheets is also set so that anyone with the link can edit the sheet, even anonymously.
Would appreicate any help!
Thanks,
The Tame Historian