I’ve been making a game with menu-driven dialog, using the Questions extension by Michael Callaghan. It works well, except when I try to make a nested menu. I want to be able to ask an NPC about multiple categories, with specific topics listed for each category. The top level menu works fine, but the submenus don’t, and I can’t seem to fix it. Here’s an example:
"TestProject" by Spirit
Include Questions by Michael Callaghan.
The library is a room.
Steven is a person. Steven is in the library.
Include Questions by Michael Callaghan.
test me with "talk to steven / 2 / 1".
StevenTopics is a list of text that varies. StevenTopics is initially {"Books", "People", "Nevermind"}.
StevenBooks is a list of text that varies. StevenBooks is initially {"History", "Thrillers", "Fantasy", "Nevermind"}.
StevenPeople is a list of text that varies. StevenPeople is initially {"Matt", "Alice", "John", "Nevermind"}.
Talking to is an action applying to one thing.
Understand "talk to [something]" as talking to.
Carry out talking to Steven:
say "Steven looks up from his book, looking slightly annoyed. 'What is it now?'";
now current question is "Ask about:";
now current question menu is StevenTopics;
now current prompt is "Choose Topic Number >";
ask a closed question, in menu mode;
A menu question rule (this is the Steven root conversation rule):
If the command prompt is "Choose Topic Number >":
if the number understood is less than 1:
say "That's not a valid option.[line break]";
retry;
else if the number understood is greater than the number of entries in StevenTopics:
say "That's not a valid option.[line break]";
retry;
Let T be the number understood;
let TopicText be entry T in the current question menu;
if TopicText is "Nevermind":
say "Steven shakes his head and mutters as he returns to his book.";
else:
try asking Steven about "[TopicText]";
exit.
After asking Steven about "books":
say "Steven nods toward the card catalog. 'What genre?'";
now current question is "Available Books:";
now current question menu is StevenBooks;
now current prompt is "Choose a Genre >";
ask a closed question, in menu mode;
A menu question rule (this is the Steven book conversation rule):
If the command prompt is "Choose a Genre >":
if the number understood is less than 1:
say "That's not a valid option.[line break]";
retry;
else if the number understood is greater than the number of entries in StevenBooks:
say "That's not a valid option.[line break]";
retry;
Let T be the number understood;
let TopicText be entry T in the current question menu;
if TopicText is "Nevermind":
say "Steven shakes his head and mutters as he returns to his book.";
else if TopicText is "History":
say "Steven recommends The Grapes of Wrath.";
else if TopicText is "Thrillers":
say "Steven recommends The DaVinci Code.";
else if TopicText is "Fantasy":
say "Steven recommends the Lord of the Rings.";
exit.
After asking Steven about "people":
say "Steven raises an eyebrow. 'Who?'";
now current question is "People:";
now current question menu is StevenPeople;
now current prompt is "Who do you want to ask about? >";
ask a closed question, in menu mode;
A menu question rule (this is the Steven people conversation rule):
If the command prompt is "Who do you want to ask about? >":
if the number understood is less than 1:
say "That's not a valid option.[line break]";
retry;
else if the number understood is greater than the number of entries in StevenPeople:
say "That's not a valid option.[line break]";
retry;
Let T be the number understood;
let TopicText be entry T in the current question menu;
if TopicText is "Nevermind":
say "Steven shakes his head and mutters as he returns to his book.";
else if TopicText is "Matt":
say "Steven says, 'Matt is friendly but not very reliable.'";
else if TopicText is "Alice":
say "Steven says, 'Alice is usually very punctual.'";
else if TopicText is "John":
say "Steven says, 'John takes long lunch breaks most days.'";
exit.