Consecutive (branched) menu questions

I’m trying to make a menu question which leads to a further menu question.
This is my generic script:

Include Questions by Michael Callaghan.

The place is a room.
The item is in the place.

After examining the item:
	now current question is "Question 1?";
	now current question menu is {"A", "B", "C"};
	ask a closed question, in menu mode;
	follow the q1 rule.
	
A menu question rule (this is the q1 rule):
	if the current question is "Question 1?":
		if the number understood is 1:
			now the current question is "Question 2?";
			now the number understood is 0;
			now current question menu is {"A", "B", "C"};
			ask a closed question, in menu mode;
			follow the q2 rule;
		exit.

A menu question rule (this is the q2 rule):
	if the current question is "Question 2?":
		if the number understood is 1:
			say "Hi";
		exit.

I included now the number understood is 0; just because otherwise the game recognizes the answer to the first question as the same answer to the second.

The problem is that when I try to give an answer to the second question the game says I didn't understand that sentence. and the game continues as the question was ended:

place
You can see an item here.

x item
You see nothing special about the item.

Question 1?
1 - A
2 - B
3 - C

Please select a number between 1 and 3 >1
Question 2?
1 - A
2 - B
3 - C

Please select a number between 1 and 3 >1
I didn’t understand that sentence.

Please select a number between 1 and 3 >

Any idea, please?

Setting the number understood to 0 does not solve the underlying problem, because now, when the second question is asked, the system thinks that the player gave the answer 0, which one can see by testing if the number understood is 0 inside the q2 rule.

The fact that the prompt stays the same as if a question was being asked (“Please select a number between 1 and 3 >”), even though the game is now actually in the normal mode of accepting parser input, indicates that the usual cleaning-up mechanisms of the extension were not called.

I think the underlying problem is that in your structure, you force the q2 rule to be followed before the q1 rule is properly exited.
In the extension’s source code, we can see what the extension normally does in the course of asking a menu question:

Section 4 - Processing menu questions

After reading a command when menu question mode is true:
	follow the menu question rules;
	if the outcome of the rulebook is the exit outcome:
		deactivate menu question mode;
		follow the every turn rules;
		follow the advance time rule;
		reject the player's command;
	if the outcome of the rulebook is the retry outcome:
		reject the player's command;
	if the outcome of the rulebook is the parse outcome:
		deactivate menu question mode.

So basically, we want the exit outcome for q1 to happen before asking q2.

Long story short, I tried adapting the example given in the extension, which uses a scene to structure the sequence of questions.

The following seems to work fine:

Include Questions by Michael Callaghan.

The place is a room.
The item is in the place.

Instead of doing anything when Gathering is happening and stage is not complete:
	 say "You are under a strange compulsion and unable to move."
	
Data is a kind of value. The data are q1, q2, and complete.

Gathering is a scene. Gathering begins when we have examined the item for the first time.
Gathering ends when stage is complete.

Stage is data that varies.
When Gathering begins:
	 now stage is q1.

Every turn during Gathering:
	if stage is q1:
		now current question is "Question 1?";
		now current question menu is {"A", "B", "C"};
		ask a closed question, in menu mode;
	if stage is q2:
		now current question is "Question 2?";
		now current question menu is {"A", "B", "C"};
		ask a closed question, in menu mode.
	
A menu question rule (this is the tough-questions rule):
	if Gathering is happening and stage is q1:
		if the number understood is 1:
			say "Okay, right answer. Going to ask Q2 in a moment.";
			now stage is q2;
		otherwise:
			say "Sorry, wrong answer.";
			now stage is complete;
		exit;
	if Gathering is happening and stage is q2:
		say "Okay, you also answered Q2, thanks.";
		now stage is complete;
		exit.

I hope this helps! :slight_smile:

Thanks a lot!
It works very well!