Opening a Door with a Password (Inform 7)

I’m having some trouble with Inform 7. I want to make it so that a door is locked, as is only unlocked when the player says “please.” I’m very new to the program and I’m having difficulty understanding how to achieve this. Here is my current code, which is really getting me nowhere:

[code]The gate is east of the Gate_Forest and west of the West_Forest. The gate is a door. The gate is lockable and locked. “Beyond, you see a large wooden gate, hidden in the trees.”

Please is an object.

Saying is an action applying to one thing. Understand “say [something]” as saying.

Check saying:
if the noun is please:
say “The door unlocks.”;
now the gate is unlocked;
otherwise:
say “Your voice echoes through the forest. No response.”[/code]

Anyone have any ideas? Thanks in advance!

You kind of have the idea, but it might be better to make a more specific action. “Please” doesn’t need to be an object.

Here’s what I would do.

[code]Pleading is an action applying to nothing. Understand “please” and “say please” and “say please to door” and “tell door please” as pleading.

Check pleading:
if the player can touch the magic door and magic door is locked:
now magic door is unlocked;
say “The door appreciates you asking nicely, and you hear a click.”;
otherwise:
say “Your request goes unanswered.” instead.[/code]

Yes, that’s perfect! I guess I have to get used to being more specific. Thank you for your help!

I agree that “please” doesn’t need to be an object in this case, but you should use the door object in the grammar. When you hard-wire the entire command like that, you’re bypassing all of Inform’s synonym mechanisms. Also “it” and so forth.

I’d set up the grammar like “say please to [something]”, “tell [something] please”, and so on.

Very true - In an extensive game where you’re working a lot with doors, you certainly should wire it up correctly to get along with the world model. My suggestion was the “quick and dirty” solution (which I use to work around potential weird commands the player might try that will goof up the parser.)