"Questions" extensions

I am at the end of my rope. I’ve spent several days trying to get what I want from Michael Callaghan’s extension, but it (expectedly) follows a different paradigm than INFORM 7: the player inputs data instead of commands.

I want to create a person (person->adventurer->class) with a name (text), gender, class (one of four text options), and a Dex (number). Although “Questions” should be perfect for this, I am at a loss to get it to work. I can get one question to work, then after that, it falls apart; usually the most recent question overwrites the others.
Can someone help or I will give up and go to Java for this.

"Character Generator" by Clyde Falsoon

Include Questions by Michael Callaghan.


Lobby is a room. 
Description of Lobby is "Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams. We are meeting now so all players can define their adventurers.";

[Player count and team size.]
NbrAdventurers is a number that varies. 

[Names for each of the adventueres.]
An adventurer is a kind of person. 
A fighter, cleric, scout, and magician are kinds of adventurers.

Z is a male fighter. [template character]

An adventurer has some text called adv_name.
An adventurer has a gender.
An adventurer has some text called adv_class.
An adventurer has a number called dex.

Data is a kind of value. The data are teamSize, stName, stSex, stClass, stDex, and complete.
Stage is data that varies.

[Initialize the stage states.]
When play begins:
	now stage is stName;
	

Every turn when stage is stName:
	now current question is "";
	now current prompt is "What is the name of the character? ";
	 now punctuation removal is true;
	ask an open question, in text mode;
		
A text question rule when stage is stName:
	[now the name of Z is current answer";]
	now stage is stSex;
	exit.

Anyone know how to make a female cleric adventurer named Kate, with a Dex between 8 and 18?

1 Like

I got a run-time error when I run the code that I’m not advanced enough to fix, but if you use SHOWME Z it will give the correct adv_name and dex.

code
"Character Generator" by Clyde Falsoon

Include Questions by Michael Callaghan.

Lobby is a room. 
Description of Lobby is "Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams. We are meeting now so all players can define their adventurers.";

[Player count and team size.]
NbrAdventurers is a number that varies. 

[Names for each of the adventueres.]
An adventurer is a kind of person. 
A fighter, cleric, scout, and magician are kinds of adventurers.

Z is a male fighter. [template character]
Z is in Lobby.
	
An adventurer has some text called adv_name.
An adventurer has a gender.
An adventurer has some text called adv_class.
An adventurer has a number called dex.

Data is a kind of value. The data are teamSize, stName, stSex, stClass, stDex, and complete.
Stage is data that varies.

[Initialize the stage states.]
When play begins:
	now stage is stName;
	

Every turn when stage is stName:
	now current question is "";
	now current prompt is "What is the name of the character? ";
	 now punctuation removal is true;
	ask an open question, in text mode;
		
A text question rule when stage is stName:
	now the adv_name of Z is current answer;
	now the dex of Z is a random number from 8 to 18;
	say "The name of your character is [adv_name], and they have a dexterity of [dex].";
	now stage is stSex;
	exit.

The run-time error is because we need to specify to which object the property belongs, so instead of:

say "The name of your character is [adv_name], and they have a dexterity of [dex].";

… it should be:

say "The name of your character is [adv_name of Z], and they have a dexterity of [dex of Z].";

There’s an exception to that, namely in a description when Inform already knows which object we are referring to. So this would work, for example:

The description of Z is "The name of your character is [adv_name], and they have a dexterity of [dex].".

Here’s one way to ask the player several questions in a row:

Include Questions by Michael Callaghan.

Lobby is a room. 
Description of Lobby is "Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams. We are meeting now so all players can define their adventurers.";

[Player count and team size.]
NbrAdventurers is a number that varies. 

[Names for each of the adventueres.]
An adventurer is a kind of person. 
A fighter, cleric, scout, and magician are kinds of adventurers.

Z is a male fighter. [template character]

An adventurer has some text called adv_name.
An adventurer has a gender.
An adventurer has some text called adv_class.
An adventurer has a number called dex.

Data is a kind of value. The data are teamSize, stName, stSex, stClass, stDex, and complete.
Stage is data that varies.

After looking for the first time:
	now stage is stName;
	now current question is "";
	now current prompt is "What is the name of the character? ";
	now punctuation removal is true;
	ask an open question, in text mode;
    
A text question rule when stage is stName:
	now the adv_name of Z is the current answer;
	now stage is stSex;
	exit.
	
Every turn when stage is stSex:
	now current prompt is "What is the gender of the character? ";
	ask an open question, in gender mode;

A gender question rule:
	now the gender of Z is the gender understood;
	now stage is stClass;
	exit;

Every turn when stage is stClass:
	now current prompt is "What is the class of the character? ";
	ask an open question, in text mode;
	
A text question rule when stage is stClass:
	now the adv_class of Z is the current answer;
	now stage is stDex;
	exit;

Every turn when stage is stDex:
	now the dex of Z is a random number from 8 to 18;
	say "[line break]Okay, you created [adv_name of Z], [gender of Z] [adv_class of Z], with a dexterity of [dex of Z].";
	now stage is complete;

Output:

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

Lobby
Welcome to the Ugly Ogre Inn! Excitement-starved adventurers meet here to form teams. We are meeting now so all players can define their adventurers.

What is the name of the character? Kate
What is the gender of the character? f
What is the class of the character? cleric

Okay, you created Kate, Feminine cleric, with a dexterity of 14.

>

There are various ways to tweak this. For example, I just accept whatever the player types as the class, and don’t check it against the available classes. You might want to offer a menu choice instead. And the extension has its own pre-defined gender options, which we would need to take into account (for example, to make sure that Z is actually female in Inform’s own sense, after the player answers “feminine” in the term of the extension – type “showme Z” to see that Z is still male in Inform’s categorisation at the end of the character creation).

If you want the player to set a non-random Dex value, then you can “ask an open question, in number mode;” together with “A number question rule when stage is stDex:”, in which you check whether “the number understood” is within the limits.

This is just intended as a basic demo of how we could ask several questions using the extension.

The example “Open Sesame” that’s included with the extension covers such a character questionnaire scenario, by the way, so you might be able to use parts (or most) of it for your game.

3 Likes

Thank you so much! (You can’t see that I’m jumping for joy. I was ready to give up.) I was only hoping for a leg up on this solution. I will study this code and make the appropriate tweaks.

2 Likes