Exporting a variable to excel/anything

Hi all,

I’m really new to using Twine, hence this may be a newbie question (or just irrelevant). I’m using Twine Harlowe as a research tool for my master’s thesis. At a certain point during the study, participants will be directed to the Twine story in which they interact with a fictional robot. They either get the option to respond friendly and encouraging, or mean and dismissive (I’m trying to measure antisocial behaviour).

I’ve created THE most basic variable to keep track of what choices users are making. At the start of the story, I’ve set a variable $count to 0. If participants make a friendly choice, $count goes up by 1. If participants make an antisocial choice, $count goes down by 1.

Easy enough, right?

Problem is, I absolutely need a way to export whatever the value of $count is by the end of the story, since it’s integral to the research design, and I would hate to have to rely on participants to report whatever number they got (or obfuscate it with some symbol or colour and have them report that). It introduces too much encertainty.

I’ve browsed this forum quite a bit, I asked my flatmate who studies IT if he could help, and I’ve also turned to chatGPT to try and give me some code that works.

I know some Python but I’m clueless with javascript and CSS. Is there anyone that can help me?

Thanks in advance!

1 Like

It might be possible with some JavaScript with Harlowe, maybe turning it into a json file. (Sorry I can’t be of help in that regard either).

If you are not set on only using Harlowe as a format, I know it is possible in the SugarCube format (since Chapel made a custom macro for it).

1 Like

Is the goal to report this info back to you? You might want to search around for “Twine analytics” or “Twine metrics”, e.g. this thread: Metrics on clicks through story

1 Like

It can be done, Eva, but it’s not something native to any Twine story format.

You can tie into browser capabilities with Harlowe through JavaScript.

You (or your IT friend) need to establish how you want to collect the data. If the Harlowe program is run through the browser on different devices, then you’ll need a method of collecting the data online (via a server – database / text file) and serving the Harlowe game (from a webserver).

If the Harlowe program is run locally (and always on the same machine – at the school), you don’t need the internet and can use a text file (like Manon linked to – though I believe it prompts the user the save the file though)… or you might want to simply use the local storage abilities of browsers. Though a user can flush the local storage (in the browser settings) and sabotage your data. (With that said, they could also delete the text files so maybe the point is moot.) Ideally, online server storage is best, but local storage is easiest and you can make a passage in your Harlowe story to access the stored data.

My suggestion is to ask your IT friend how they would collect the data and set that up if it’s online. Then we can help you submit the user’s data that through JavaScript within Harlowe. The link Andrew shared touches upon finding an online service to collect the data. This is outside the scope of Harlowe (client-side) and more about webserver technology (server-side).

Long story short… local storage or online storage? How do you want to do it?

1 Like

Oh this was what I was looking for! Saves me a massive headache, thank you. I guess I’ll have to change the format to sugarcube then but I don’t think that’s a big issue. Just a lot of copy and pasting.

I’ll try to make it work. Thanks again! <3