A hotel door: always locked on one side, open on the other

I’m new to Inform development. What is the simplest way to do this?

There is a hotel room with a door into a hallway. From inside the room, it is always possible to open the door and exit. The door always closes and locks behind you. From outside, the player can only unlock, open, and enter if he has the key.

(If one has the key, then unlocking and opening the door from the outside do need to be explicit, but they might be automatically narrated.)

OK, I think I figured it out. What a fun language! Let me know if you can think of a way to improve it:

Check opening the hotel door:
	if the player is in the Corridor and the player is not carrying the key:
		say "You don't have the key." instead.

After going through the hotel door:
	now the hotel door is closed;
	say "The door closes and latches tightly behind you.";
	continue the action.

That way seems pretty good, but it’s certainly not the only way; when I did this, I closed the door in an “Every turn” rule (which means that if they don’t have the key, they can get back in before the door closes if they act quickly) and I also kept the door locked in addition to being closed - it’s automatically unlocked with a “Before” rule if you’re in the room or if you have the key.

Before an actor opening the hotel door:
	if the location is the hotel room:
		now the hotel door is unlocked;
		say "You unlock the door.";
		now the hotel door is unlocked.

Every turn when the hotel door was open:
	say "The door swings shut.";
	now the hotel door is closed;
	now the hotel door is locked.

The way you came up with is perfectly fine, though. The Every Turn rule provides an alternate flavour, and the other detail (making the door locked) doesn’t make much difference unless you’re doing pathfinding between rooms. Using Before instead of Check also doesn’t really mean much.

Note that with your code, an NPC would be able to open the door. Since NPCs only do things if the code tells them to, though, that might not be an issue.