Prompt for Keyword/Return to first prompt if failed

Hey, y’all!

I’m working on a small program for a friend, sort of a quiz review-type thing.

Is there any way for me to have certain prompts, as in an object does “say ‘what is 2+2’”, then whatever you type next will be compared to the true answer. If correct, the next problem will be displayed, such as 4+4, but if that is failed, the program returns to asking what 2+2 is. It should end after several questions with a variable changing from false to true.

If anyone knows how I would go about this, I’d be very thankful.

The Questions extension? … oc_26.html

Another way would be to check the command prompt.

When play begins:
 now the command prompt is "what is 2+2? >"

After reading a command when the command prompt is "what is 2+2? >":
 if the player's command matches the regular expression "4|four":
  say "correct!";
  now the command prompt is "what is 6*8? >";
  say "Incorrect!";
 reject the player's command.

Sorry about possible errors. I’m on my phone.

1 Like