How to lock a door behind oneself

Hello,
How can a door lock oneself automatically with out any player input?
Thank you. :smiley:

-Gloucester

After going through an openable lockable door (called the portal): now the portal is closed; now the portal is locked; say "You conscientiously shut and lock [the portal] behind you."; continue the action.

“Continue the action” is necessary because otherwise the game will not print the description of the room you end up in.

You could also use something like this:

A door can be automatic.
Every turn when an automatic lockable door was open:
	repeat with portal running through every open automatic lockable door:		
		if the player can see the portal:
			let R be the other side of the portal from the location of the player;
			say "The door to [the R] swings shut.";
		now the portal is closed;
		now the portal is locked.

This code makes the door close one turn later than Mike’s code - where his version makes it close the moment you pass through it, mine doesn’t make it close until the next turn. So in my version the player has a chance to go back through before it locks.

Thank you! :slight_smile: