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.