0 votes
by (230 points)

Thread 1

Thread 2

Updating from my last question. The script of importing twine data to google sheets now worked. My previous issue was that no data was being imported so I created a new sheet and added the script onto the new one and it is now recording the data.
However, when I checked my sheet the history column only recorded one passage. I used this to record the passages visited by the player and turned it into a variable:

(set: $history to (history:))

I thought it should have recorded everything and the column in the google sheet should have contained them, but it only has one recorded data which is my introduction passage. See here.

Is there any way to have all passages visited recorded into the column?

I also uploaded the html file I used should you need to examine it further.

1 Answer

0 votes
by (159k points)
edited by
 
Best answer

I'm not an expert when it codes to either Google App Scripts or Google Spreadsheets, but as I understand things you can't store an Array object directly within a Spreadsheet cell. You can however use something like the <Array>.join(',') fuction to convert that Array to a coma seperated String value and store that in the cell instead.

Because you didn't supply an example of your current App Script I will assume that it still looks something like the one found here

Change the following section of the above linked code from:

// loop through the header columns
for (i in headers){
	if (headers[i] == "Timestamp"){ // special case if you include a 'Timestamp' column
		row.push(new Date());
	} else { // else use header name to get data
		row.push(data[headers[i]]);
	}
}

to the following which checks for and converts Array objects...

// loop through the header columns
for (i in headers){
	if (headers[i] == "Timestamp"){ // special case if you include a 'Timestamp' column
		row.push(new Date());

	} else if (data[headers[i]] instanceof Array) { // convert Array to formatted String
		row.push(data[headers[i]].join(','));
        
	} else { // else use header name to get data
		row.push(data[headers[i]]);
	}
}

The re-publish the new version of your App Script, you may near to advance the version number for it to actually overwrite the existing published one.

by (230 points)
My bad for not providing the script! But you guessed right that I was using the same one in my previous question.

Your suggestion worked like a charm! All the passages have all been recorded and I can finally move on to creating my actual game.

Thanks a lot!
...