I have used Dan Cox's tutorial on Working with Google Sheets in Twine to be able to log gameplay data from my game.
Now, however, I need to do the reverse: instead of porting data out of Twine into Google Sheets, I need to be able to pull from Sheets into Twine. This is for a research project, and in order to map each gameplay onto the right subject/player, I need to have each log in with a specific ID.
Unfortunately, I can't just use a simple array with a pre-set list of IDs for the user to log-in and check against; I need to be able to dynamically update the list of IDs without updating the Twine game itself. If I DO use an array in Twine, I can get the conditional and log-in to work just fine; I just can't get it to work with an external array.
Thought I'd use Google Sheets, but I can't manage to get it to work. I'm not super-skilled with Javascript, which may be the problem. I've tried using sheetrock.js's "results" variable as an array to check the user-inputed IDs against, as well as using fetch from Google API. Every attempt returns the same result: the Twine IF conditional never reads the variable - it's always undefined.
I don't really have code, because absolutely nothing works. Here's the static array that works, if that helps.
<<silently>><<set
$validIDs to [
"roseslug",
"demo",
"beta"]
>>
<</silently>>
<<textbox "$codename" "" autofocus>>
<span id="textbox-reply"></span>
<span id="textbox-submit">\
<<button "Log In">>
<<set $codename to $codename.trim().toLowerCase().replace(/\s\s+/g, "")>>
<<if $validIDs.contains($codename)>>
<<goto [[Start]]>>
<<else>>
<<replace "#textbox-reply">>\
Incorrect codename. Please try again.\
<</replace>>
<</if>>
<</button>>\
</span>