So I am in the throes of trying to write a scene where a professor (of magic) asks students quiz questions. I am trying to use a table to cycle through the questions. I’ve gotten very close–parts of the code have compiled and worked–but I haven’t been able to make the code do all of the following:
- Ask questions one at a time.
- Read the player’s input.
- Compare the player’s input to an answer.
- Either reward or punish the player for being right or wrong (respectively).
- Move on to the next question, after a bit of colorful dialogue.
So here, in simplified form for easier reading, is my code. It does not currently compile, but I think the error message it is giving me about misaligning my “ifs” and “otherwises” isn’t the issue. Please try not to faint at the code’s inelegance:
The Dueling Pit is a room. "Scorch marks and dried blood adorn the Dueling Pit. Does the board of education know about this place?".
Professor Dimflame is a man in the Dueling Pit. "Professor Dimflame: the bane of all freshman at Margram Academy.".
Tyra is a woman in the Dueling Pit. "Your opponent for today is Tyra. She looks like she wants to set you on fire.".
Every turn during Monday Testing:
if the score is zero:
say "I think you should study sentence objects a little more before you try to duel Tyra again. [paragraph break] GAME OVER";
end the game in death.
When Monday Testing begins:
say "Professor Dimflame, his face somewhere between annoyed and amused, says, 'Well, for better or worse, it[']s time to begin the duel. Perhaps I should give you two football helmets to wear? Oh, but that wouldn't be nearly as funny. What was I thinking? Okay, [player's forename in title case], you're up. Here is your next question.'[paragraph break] Dimflame gives you a mean squint, then asks you,[paragraph break][Query entry in row one of the Table of Quiz Queries]'":
if the player's command matches "[topic entry in row one of the Table of Quiz Queries]":
award 1 point;
consider the custom notify score changes rule;
say "[Correct entry][paragraph break] Ready for the next one?";
change the current challenge to the current challenge + 1;
reject the player's command;
otherwise:
award -1 point;
consider the custom notify score changes rule;
say "[Incorrect entry][paragraph break] You'd better start getting more answers correct!";
change the current challenge to the current challenge + 1;
reject the player's command;
consider the quiz problem rule.
The current challenge is a number that varies. The current challenge is 1.
Before doing something during Monday Testing:
say "Ready for the next one?";
consider the quiz problem rule;
reject the player's command.
This is the quiz problem rule:
repeat through the Table of Quiz Queries:
if the number entry is the current challenge:
say "[query entry]";
consider the check answer rule;
otherwise:
say "The quiz is over.".
This is the check answer rule:
let N be the value of the current challenge;
if the player's command matches the topic entry in row N of the Table of Quiz Queries:
award 1 point;
consider the custom notify score changes rule;
say "[Correct entry][paragraph break]";
change the current challenge to the current challenge + 1;
reject the player's command;
rule succeeds;
otherwise:
award -1 point;
consider the custom notify score changes rule;
say "[Incorrect entry][paragraph break]";
change the current challenge to the current challenge + 1;
reject the player's command;
rule succeeds.
Table of Quiz Queries
Number Query Topic Correct Incorrect
1 "What is the object of line five of the poem?" "it" "Correct!" "Wrong."
2 "What is the object of line six of the poem?" "wand" "Right!" "Quite wrong."
3 "What is the object of line eight of the poem?" "ground" "Good!" "Wrong wrong wrong."
4 "What is the object of line ten of the poem?" "prince" "Well done!" "Nope."
5 "What is the object of line eleven of the poem?" "none" "Excellent!" "Just plain wrong!"
-- -- -- -- --
N.B. The table is correct in my code, but it is almost assuredly misaligned as pasted above.
Any/all help is greatly appreciated. I was thinking, as a small but earnest thank-you, to offer those who help with the game a cameo role in “Margram” (that’s the IF I am working on) as one of the wizard-professors. If you have helped or are helping me now, let me know if you would like to be immortalized in the game!