I just want to create a door with a password (ANSWERED!)

Firstly off, please take pity on me. - I am very new to Inform7 (I just started my story last week) I have been cruising along, with a few tiny bumps in the road… but this recent one just baffles me!

I want to create a door which when examined opens an interface to give the password. The password being text that the user enters. (let’s say “giggity”) I have tried a few different approaches. I have been at this for 2 days now. Can anyone please help me out?
Here is my most recent try (which includes “Questions” by Micheal Callaghan, but I have obviously butchered it - as it throws out errors-galore):

A text question rule:
	if the current question is "Can you picture the password?":
		if text understood is giggity:
			say, "**BUZZ**  You have unlocked the security door.";
			now the security terminal is unlocked;
			exit;
		otherwise:
			exit;
	otherwise:
		exit.

A yes/no question rule (this is the confirm answers rule):
	if the current question is "Would you like to try again? (Yes or No)":
		if the decision understood is yes:
			examine security terminal;
		otherwise:
			say "Goodbye.";
			exit;
	otherwise:
		exit.

Instead of inspecting security terminal:
	now the current question is "Can you picture the password?";
		now current prompt is "Please enter the password now. >";
		now punctuation removal is true;
		ask a closed question, in text mode;
	now the current question is "Would you like to try again? (Yes or No)";
	ask a closed question, in yes/no mode.[/size]

I did consider making the security door the door and security terminal a person, who can ask for the password using the [topic] table. I do not know if a dialog can trigger an action though(like ‘now the security door is unlocked.’). Plus, I haven’t played around with adding characters yet and don’t really know what I’m doing at all there.

Props on the Family Guy reference, if that’s what it was. My favorite show of all time.

Otherwise, I can’t help you. Sorry.

Yeah, I was watching it earlier today and it was the first thing that popped into my head. :wink:

Here’s a way:

The description of the security terminal is "Can you picture the password?"
After examining the security terminal:
	now the command prompt is "Please enter the password now. >";
	continue the action.
	
After reading a command when the command prompt is "Please enter the password now. >":
	increment the turn count;
	if the player's command matches "giggity": 
		now the security door is unlocked;
		say "**BUZZ**  You have unlocked the security door.";
		now the command prompt is ">";
	otherwise:
		say "The security door remains closed.";
		now the command prompt is "Would you like to try again? (Yes or No) >";
	reject the player's command.	
	
After reading a command when the command prompt is "Would you like to try again? (Yes or No) >":
	if the player's command matches "yes" or the player's command matches "y": 
		now the command prompt is "Please enter the password now. >";
		say line break;
		say run paragraph on;
		reject the player's command;
	if the player's command matches "no" or the player's command matches "n": 
		now the command prompt is ">";
		say line break;
		say run paragraph on;
		reject the player's command;
	otherwise:
		say line break;
		say run paragraph on;
		reject the player's command.

Thank you SO much for your time and for trying to help!
That looks similar to my first try, but i have never used “run paragraph on” before. What does that do?

Also it’s still giving me errors (I just copied and pasted, so that I wouldn’t mess up your code):

[code]Problem. The phrase or rule definition ‘After reading a command when the command prompt is “Please enter the password now. >”’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘if the player’s command matches “Keep” or the player’s command matches “keep”’ , in case that helps.

This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.[/code]
It is giving me the same error for the first line in the next set also ‘After reading a command when the command prompt is “Would you like to try again? (Yes or No) >”:’
Perhaps there is some extension that you usually include that makes this work? If so, which one?

Ah, you’re being caught by the forum trick. The problem with copying and pasting from the forum is that if you copy from a post, the tabs have all been converted to spaces, and Inform really requires them to be tabs. One way to quickly work around that is to make as if to reply to the post containing the code (so, hit the “quote” button), then copy the code from within the reply-to text box, where the tabs will be magically restored to how the original poster typed them in. Of course, if the original poster typed them in as spaces, you’ll still need to convert them to tabs by hand.

Ok, I figured it out - my copy and paste job reads your code as having 3 spaces instead of a tab. I replaced all of the spacing with tabs and it worked PERFECTLY!!

THANK YOU Felix!! :smiley:

(thank you Trove - you were replying just as i was! That certainly beats the way I did it! I will keep that in mind for the future.)

This happens so often that maybe it would be a good idea to make a post with general instructions and make it sticky?

You need to print a line break (or paragraph break) after the player has answered the question or there will be no blank line between the line with the answer and the new command prompt that follows the answer.
However, I found when testing the code, that (for some I6 reason, I think) the game would then print TWO blank lines between the lines rather than one.
This happens every now and then in Inform 7, and “run paragraph on” prevents it. It stops the next paragraph from beginning on a new line, and runs it immediately on as a single paragraph with the preceeding one (or something).

Thank you again Felix, you have been very helpful!

Hi Felix.

How easy would it be to add a ‘timer’ to your example.

What I am trying to do is something similar to the above but have it time limited to a few moves as in turning off a burglar alarm when entering a house. If you do not enter the correct ‘code’ in say 10 moves then the police arrive and it’s game over.

Any tips appreciated.

Cheers.

I think it’s as simple as this:

Every turn when the alarm has been switched on for at least 10 minutes and the location is in the Expensive Mansion: say "The police arrive."; end the story saying "You go to jail.";

1 Like

When I use a similar format for entering a password, the command prompt changes, but whatever is entered, even if its the right password says “I do not recognize this verb.” Everything else works, and the result is all the write info but then at the end of the “Door is unlocked” etc. it says that it doesn’t recognize the verb even though it works.

Welcome!

This is an old topic, but when I paste the example into a current version of Inform 7 I’m not getting the error you mention. If you post your code folks here can probably take a look and see what’s going wrong – you can use the preformatted text tool (the little </> icon in the toolbar) to make it show up correctly, like this:

This is how you can post code.

     It preserves spacing and stuff that's important for Inform!
The Hotel Computer is a computer. The Hotel Computer is in Behind Counter. The description of The Hotel  Computer is "[if switched on]The computer screen prompts you to enter a password. [otherwise]The box computer monitor looks simultaneously new and old - old because the model has to be at least 15 years outdated, while new because it looks like it just came out of the box. A scanner is attached to one side." A container called the scanner is part of the computer. The description of the scanner is "For scanning key cards." 
Carry out switching on the computer:
	now the command prompt is "Please enter the password now. >";
	continue the action.
After reading a command when the command prompt is "Please enter the password now. >":
	increment the turn count;
	if the player's command matches "XYZZY": 
		say "You enter the password and the computer unlocks. The only application on the computer is the key card programmer.";
		now the command prompt is ">";
		now the description of the computer is "The only application on the computer is the key card programmer.";
	otherwise:
		say "Wrong password";
		now the command prompt is "Would you like to try again? (Yes or No) >";
		reject the player's command.	
	
After reading a command when the command prompt is "Would you like to try again? (Yes or No) >":
	if the player's command matches "yes" or the player's command matches "y": 
		now the command prompt is "Please enter the password now. >";
		say line break;
		say run paragraph on;
		reject the player's command;
	if the player's command matches "no" or the player's command matches "n": 
		now the command prompt is ">";
		say line break;
		say run paragraph on;
		reject the player's command;
	otherwise:
		say line break;
		say run paragraph on;
		reject the player's command.

I think you need a “reject the player’s command” instruction in the block of code under “if the player’s command matches ‘XYZZY’” conditional – adding that in seems to take care of the issue (if you don’t reject it, the game will try to execute XYZZY as a command – but since you haven’t set up anything to happen when the player types that, you’re getting the “I don’t recognize that verb” parser error. If you did have an easter-egg type response for XYZZY, you’d see that fire off after the “You enter the password…” gets printed out).

Hope that’s helpful!

Thank you that worked perfectly! I’ve only programmed one game with Inform, and am working on a more ambitious project now, I’m very glad I found this forum!!

1 Like