I’m writing an interrogation scene. Running through a series of questions, the player’s answers will be stored in a list. (Ideally the questions would come in random order.) I’ve tried looping through a table of “kuestion” entries, but rejecting the player’s command results in another prompt (instead of the next question) until a legitimate command is entered.
In the second half, I want to ask the same questions (hopefully in random order). If the player’s new answers don’t match the previous answers, the story changes. I need a better trigger for the end of the first round of questioning; right now, Scene1 ends/Scene2 begins before the last answer of Scene1 is given.
I tried to add my table of questions to the Open Sesame example from Michael Cunningham’s Questions extension. Somehow I broke the example so that the parser doesn’t accept non-command text entries any more. (The example worked fine before I messed with it.)
I’ve been struggling for over a week, so I’m very grateful for your help.
Include Basic Screen Effects by Emily Short.
InterroIndex is initially 1.
Missteps is initially 0.
QGoodbye is initially false.
The Interrogation Room is a room. The description of the Interrogation Room is "This is a small room in a facility."
Holding Tank is a room.
Round1 is a scene. Round1 begins when play begins.
Rule for printing a parser error when the latest parser error is the not a verb I recognise error:
if the location is the interrogation room:
now entry Interroindex in myArray is "[the player's command]" instead.
myArray is a list of text that varies. myArray is {"", "", "", "", ""};
[I get errors if I don't initialize to these nulls.]
Table of Round1Qs
Index Kuestions1
1 "Who?"
2 "What?"
3 "Where?"
4 "When?"
5 "How?"
Every turn during Round1:
choose a random row in Table of Round1Qs;
say "[Kuestions1 entry][paragraph break]";
now InterroIndex is Index entry;
blank out the whole row;
Rule for printing a parser error when the latest parser error is the not a verb I recognise error:
if the location is Interrogation Room:
add player's command at entry InterroIndex in myArray;
Round1 ends when the number of filled rows in the Table of Round1Qs is 0. [This happens before the answer is received.]
Round2 is a scene. Round2 begins when Round1 ends. [Round2 is starting before we get the answer to the fifth question.]
When Round2 begins:
Say "Someone else takes over for Round 2.";
Table of Round2Qs
Index Kuestions2
1 "Como?"
2 "Cuando?"
3 "Que?"
4 "Quien?"
5 "Donde?"
Every turn during Round2:
choose a random row in Table of Round2Qs;
Say "[Kuestions2 entry][paragraph break]";
If entry Index entry in myArray is not "[player's command]":
increment Missteps;
blank out the whole row;
Round2 ends when the number of filled rows in the Table of Round2Qs is 0.
Goodbye is a scene. Goodbye begins when Round2 ends. Goodbye ends when QGoodbye is true.
When Goodbye begins:
say "[if Missteps is greater than 0]The inspector pulls out a big rubber stamp. [end if]The session is over.";
now QGoodbye is true.
When Goodbye ends:
now the player is in Holding Tank;
I haven’t actually worked with the Questions extension, so maybe this is a dumb question/thing to point out, but in your example code you don’t actually include the extension (just the Emily Short one). My understanding is that the way the extension works is that the player can input any text they want in a form that you can then store in a list or recall later, without that leading to a parser error if that’s anything other than a valid action, as you currently seem to be getting – it looks like what you’re doing now is attempting to jury-rig the parser error system to do what the extension already should be doing?
As you’re experiencing, doing that is probably not a good idea (the specific issue you’re running into, I think, is that when player input leads to a parser error, that doesn’t count as a completed action and the timing rules like every turn rules and the scene-changing machinery don’t fire. But there are a lot of potential issues like this!); much better to get the extension included and working the way it should. Apologies for not having anything more specific to share, since as I said I’m not familiar with the extension and I don’t have time right now to get up to speed with it, but hopefully this is at least partly helpful!
(Or actually now that I look at this again, is what you’re actually trying to do to write your own version of a system to parse arbitrary text that the player inputs, rather than relying on the extension? Even if that’s the case, I’d probably still look at how the extension does things and try to implement a cut-down version of that, rather than overload parser errors like this).
Yes, I’ve made multiple iterations. This is what I was working with before I discovered the extension. It almost works-ish. The version where I try to use the Questions extension is completely broken.
(The Basic Screen Effects works fine for another part of this scene. I just forgot to streamline it out of there for posting.)
Include questions by Michael Callaghan.
entryIndex is a number that varies.
answersList is a list of text that varies. answersList is {"", "", "", "", ""}
badAnswers is initially zero.
The Interrogation Room is a room. "This is a small room."
Introduction is a scene.
Introduction begins when play begins.
Introduction ends when the number of filled rows in the Table of Round1Qs is 0.
When introduction begins:
follow the set open sesame rule.
Every turn when introduction is happening (this is the set open sesame rule):
choose a random row in Table of Round1Qs;
now current question is "[kweschun entry]";
now current prompt is ">";
now punctuation removal is true;
now entryIndex is index entry;
ask an open question, in text mode;
blank out the whole row.
Table of Round1Qs
index kweschun
1 "How are you?"
2 "What time is it?"
3 "How's the weather up there?"
4 "How's it going?"
5 "What's my name again?"
A text question rule (this is the open sesame rule):
if introduction is happening:
now entry entryIndex in answersList is the current answer;
otherwise:
parse.
I had a couple minutes to look at your code and glance over the extension, and with a few tweaks seems like this should work (see comments):
Include Questions by Michael Callaghan.
entryIndex is a number that varies.
answersList is a list of text that varies. answersList is {"", "", "", "", ""}
badAnswers is initially zero.
The Interrogation Room is a room. "This is a small room."
Introduction is a scene.
Introduction begins when play begins.
Introduction ends when the number of filled rows in the Table of Round1Qs is 0.
[I deleted the "follow the set open sesame rule" from your "when introduction begins" rule since that just leads to the initial question being printed above the initial location description; I assume in your actual game there'll be some lead-in to this sequence so not a big deal either way.]
Every turn when introduction is happening (this is the set open sesame rule):
If the number of filled rows in the Table of Round1Qs is not zero: [you need this since every turn rules run at the end of the round; thus, after the player answers the fifth question, all the rows will be blanked and trying to access the question entry of a randomly-chosen row will throw a runtime error]
choose a random row in Table of Round1Qs;
now current question is "[kweschun entry]";
now current prompt is ">";
now punctuation removal is true;
now entryIndex is index entry;
ask an open question, in text mode;
blank out the whole row.
Table of Round1Qs
index kweschun
1 "How are you?"
2 "What time is it?"
3 "How's the weather up there?"
4 "How's it going?"
5 "What's my name again?"
A text question rule (this is the open sesame rule):
if introduction is happening:
now entry entryIndex in answersList is the current answer;
say "Noted."; [feedback so the player knows their input was accepted]
Exit; [from the extension docs, looks like you need to do this to exit question mode; otherwise seems like the command gets passed along to the regular parser, which probably explains the issues you were seeing!]
otherwise:
parse.
Instead of jumping:
Say "[answerslist]." [to test that everything was set correctly]
From here seems like adding the second round should be fairly straightforward – hope this helps!
EDIT: and just to add, I’m generally someone who likes to write all my own code rather than use extensions. But in this case there are a lot of potential niggles – what happens if the player types SAVE in the middle of the interrogation, or just ABOUT? – that it seems like the extension helps you manage. So in this case I’d probably be tempted to go with it rather than roll my own approach.
Actually, I had a minute, so I put the pieces together:
Include Questions by Michael Callaghan.
entryIndex is a number that varies.
answersList is a list of text that varies. answersList is {"", "", "", "", ""}
badAnswers is initially zero.
The Interrogation Room is a room. "This is a small room." Holding Tank is a room.
Round1 is a scene.
Round1 begins when play begins.
Round1 ends when the number of filled rows in the Table of Round1Qs is 0.
Every turn when Round1 is happening:
If the number of filled rows in the Table of Round1Qs is not zero:
choose a random row in Table of Round1Qs;
now current question is "[kweschun entry]";
now current prompt is ">";
now punctuation removal is true;
now entryIndex is index entry;
ask an open question, in text mode;
blank out the whole row.
Table of Round1Qs
index kweschun
1 "How are you?"
2 "What time is it?"
3 "How's the weather up there?"
4 "How's it going?"
5 "What's my name again?"
Instead of jumping:
Say "[answerslist]."
Round2 is a scene. Round2 begins when Round1 ends.
When Round2 begins:
Say "Someone else takes over for Round 2.";
Table of Round2Qs
Index Kuestions2
1 "Como?"
2 "Cuando?"
3 "Que?"
4 "Quien?"
5 "Donde?"
Every turn when Round2 is happening:
If the number of filled rows in the Table of Round2Qs is not zero:
choose a random row in Table of Round2Qs;
now current question is "[kuestions2 entry]";
now current prompt is ">";
now punctuation removal is true;
now entryIndex is index entry;
ask an open question, in text mode;
blank out the whole row.
A text question rule (this is the interrogation rule):
if Round1 is happening:
now entry entryIndex in answersList is the current answer;
say "Noted.";
Exit;
If Round2 is happening:
if current answer is entry entryIndex in answerslist:
say "Aha, you're a consistent liar!";
Otherwise:
Say "A contradiction!";
Increment badAnswers;
Exit;
otherwise:
parse.
Round2 ends when the number of filled rows in the Table of Round2Qs is 0.
Qgoodbye is a truth state that varies. Qgoodbye is initially false.
Goodbye is a scene. Goodbye begins when Round2 ends. Goodbye ends when QGoodbye is true.
When Goodbye begins:
say "[if badAnswers is greater than 0]The inspector pulls out a big rubber stamp. [end if]The session is over.";
now QGoodbye is true.
When Goodbye ends:
now the player is in Holding Tank;