Extension: Questions by Michael Callaghan

Does anyone know if this extension is still viable, dated 12/19/17? Although the documentation is good, I cannot get it to work as advertised. I have seen that a couple other people are having trouble with it.
Yes, I am running Glulx.

I am having the same trouble as Stew King: only the last question in a list is asked. The prompt is not presented.
https://intfiction.org/t/problems-using-questions-by-michael-callaghan/40882Stew King

Data is a kind of value. The data are teamSize, name, sex, class, dex, and complete.
Stage is data that varies.

Gathering is a scene. Gathering begins when location is lobby.
Gathering ends when stage is complete.

When Gathering begins:
	now stage is teamSize;
		
Every turn during Gathering:
	if stage is teamSize:
		now current question is "How many adventureres will be going on this mission?";
		now current prompt is "Enter a number between 1 and 4: ";
		ask an open question, in number mode;
		now stage is name;
	else if stage is name:
		now current question is "";
		now current prompt is "What is the player's name? ";
		ask an open question, in text mode;
		
	
A number question rule (this is the count players rule):
	if stage is teamSize:
		if the number understood is greater than 4:
			say "Sorry. This mission cannot accommodate more than four adventurers.[line break]";
			retry;
		if the number understood is less than 1:
			say "Let's try to be realistic about this.";
			retry;
		now the nbrAdventurers is the number understood;
		say "OK. Your squad consists of [teamSize] adventurers."; 
		exit.

After the data is entered, the echo check SAY “OK…” is not printed. I’m not sure that the number question rule is even executed.

This version: extensions/Michael Callaghan/Questions-v5.i7x at 10.1 ¡ i7/extensions ¡ GitHub
for I10 works for me when running the quiz night example.

Phil,
Have you tried running more than one kind of question?

Sorry I think I misunderstood your problem. Could you post a complete example of the code that won’t work? I tried working with your incomplete code up there, but I encountered a different problem, and I’m not sure if I filled in the holes wrong.

You’re proceeding too early to the next stage. If you move the line “now stage is name” from where it currently is (directly after the “ask an open question, in number mode” line) to right before the “exit” line (which is when you are ready to proceed), then it works, or at least it did so for me in a short test.

So, like this (excerpt, relevant parts marked with comments):

Every turn during Gathering:
	if stage is teamSize:
		now current question is "How many adventureres will be going on this mission?";
		now current prompt is "Enter a number between 1 and 4: ";
		ask an open question, in number mode;
		[now stage is name;] [<- remove it from here]
	else if stage is name:
        .......
    
A number question rule (this is the count players rule):
	if stage is teamSize:
		if the number understood is greater than 4:
			say "Sorry. This mission cannot accommodate more than four adventurers.[line break]";
			retry;
		if the number understood is less than 1:
			say "Let's try to be realistic about this.";
			retry;
		now the nbrAdventurers is the number understood;
		say "OK. Your squad consists of [teamSize] adventurers.";
		now stage is name; [<- move it here]
		exit.
1 Like

Yes, I moved it and it worked. This whole extension seems like it either uses concurrent processing or takes advantage of Inform using concurrent processing, and yet I think neither does. It makes it very hard to think through coding problems.

Here is a new problem: duplicate questions which should not occur at all.

After looking for the first time:
	now stage is teamSize;
				
Every turn:
	if stage is teamSize:
		now current question is "How many adventurers will be going on this mission?";
		now current prompt is "Enter a number between 1 and 4: ";
		ask an open question, in number mode; 
	if stage is name:
		now current question is "";
		now current prompt is "What is the name of player 1? ";		ask an open question, in text mode;

A number question rule when stage is teamSize:
	say "Runnning number question rule. Stage = [stage][line break]";
	if the number understood is greater than 4:
		say "Sorry. This mission cannot accommodate more than four adventurers.[line break]";
		retry;
	if the number understood is less than 1:
		say "Let's try to be realistic about this.";
		retry;
	now the nbrAdventurers is the number understood;
	say "OK. Your squad consists of [nbrAdventurers] adventurers."; 
	now stage is name;
	exit.

Note two things:
[1] Despite the ‘first turn’ conditional, I am required to type something into the first prompt before the questions start.
[2] The ‘current question’ is printed twice, and I cannot set the reason for this at all.
The output is shown below.

Phil,
I appreciate your looking at the problem. My complete, and more up-to-date, code is below in another reply.

I added a ‘stop the action’ command at the end of the teamSize block in the ‘Every turn’ rule and it removed the duplicate question. Perhaps that will need to be added for each different stage value.

In your second code snippet, there’s a spot with two statements on the same line, separated by tabs. It’s the last line in this part:

if stage is name:
		now current question is "";
		now current prompt is "What is the name of player 1? ";		ask an open question, in text mode;

This throws Inform off, and seems to cause the “duplicate question” behaviour. When you put the “ask ...” part on the next line, it works correctly and only asks the (previous) question once:

if stage is name:
		now current question is "";
		now current prompt is "What is the name of player 1? ";
        ask an open question, in text mode;

I think this has to do with the way the “every turn” rules and the implicit looking action on the first turn work, and so on. One way to get the desired output would be to move the first question directly into the “After looking for the first time:” rule, like this:

After looking for the first time:
	now stage is teamSize;
	now current question is "How many adventurers will be going on this mission?";
	now current prompt is "Enter a number between 1 and 4: ";
	ask an open question, in number mode;

Output:

Release 1 / Serial number 240331 / Inform 7 v10.1.2 / D

Lobby
A lobby where adventurers gather.

How many adventurers will be going on this mission?

Enter a number between 1 and 4: 3
OK. Your squad consists of 3 adventurers.

… etc.