Prompt question

The code:

Before opening the front door:
	if the player is clean AND the player is fullup:
		say "Something.";
	else if the player is clean OR the player is fullup:
		say "A second something.";
	else if the player is dirty AND the player is hungry:
		now the command prompt is "There is a question here? > ".

After reading a command when the command prompt is "There is a question here? > ":
	if the player's command matches the regular expression "yes":
		move the player to Kitchen;
	else if the player's command matches the regular expression "no":
		move the player to Living Room;
	otherwise:
		say "I don't understand this word. Just type yes or no.";
	reject the player's command;
    stop the action.

The output:

Living room
This is the living room.

You can see a front door here.

>open front door
You open the front door.

There is a question here? > yes

Kitchen
This is the kitchen.

There is a question here? >

The prompt question keeps coming up even though I have already answered it. How can I change the code in order to make it appear only in the first time?

1 Like

Just change the prompt back after moving the player.

In this specific instance, “if the player assents” is neater. But that specifically handles yes/no questions only. I assume you want something more complex than that.

2 Likes

What exactly is the line of code for extinguishing the command prompt? I have tried a few ways but it doesn’t seem to work.

This will turn it back to the default. An empty string in this statement removes the prompt prefix–there’s still a prompt, there’s just nothing to serve as a visual cue.

now the command prompt is ">".

If you just want to ask a yes/no question the following is the built-in method:

Before opening the front door:
	if the player is clean AND the player is fullup:
		say "Something.";
	else if the player is clean OR the player is fullup:
		say "A second something.";
	else if the player is dirty AND the player is hungry:
		say "There is a question here? [line break]";
		if the player consents: 
			move the player to Kitchen;
		otherwise:
			move the player to Living Room.

Inform handles cases where the input isn’t yes or no automatically. This, of course, won’t do you any good if your question isn’t yes no.

2 Likes

I concur with Bjorn, also I think is a perfect case for the use of “if the player consents”.

Best regards from Italy,
dott. Piergiorgio.