Creating an amulet of tumblers that can be used to lock and unlock things even when it is worn, overriding the usual requirement that keys be carried.

Under most circumstances, locking and unlocking require the player to be carrying the key he uses to unlock something. This makes sense -- unless the key is on a keychain, or on a chain around his neck, for instance. So here we explore one way to circumstantially override the carrying requirements, while still making sure that the player cannot unlock the door if the unlocking tool is nowhere in sight.

In essence, we are rewriting the carrying requirements rule with a different one of our own devising, and swapping it in only at those moments when it is correct to do so.

"Slogar's Revenge"
Section 1 - Procedure
The amulet carrying rule substitutes for the carrying requirements rule when locking something with the Amulet of Tumblers.
The amulet carrying rule substitutes for the carrying requirements rule when unlocking something with the Amulet of Tumblers.

We can now replace the usual behavior of the carrying requirements rule (to check whether the player is carrying something and, if not, to generate an implicit take) with a similar rule of our own; note that "if the player has the second noun" is a more compact way to write "if the player carries the second noun or the player wears the second noun":

This is the amulet carrying rule:
   if the player has the second noun:
      continue the action;
   say "(first picking up the amulet)[command clarification break]";
   try silently taking the second noun;
   if the player is not carrying the second noun:
      stop the action;
Section 2 - Scenario
The Daunting Dungeon is a room.
West of the Daunting Dungeon is the Disturbing Door. The Disturbing Door is a door. West of the Disturbing Door is the Fallow Field.
The Disturbing Door is closed and locked.
The player wears the Amulet of Tumblers. The Amulet of Tumblers unlocks the Disturbing Door.
Test me with "unlock disturbing door with amulet / open door / west / remove amulet / close door / lock disturbing door with amulet / drop amulet / unlock disturbing door with amulet".
Test me with "unlock disturbing door with amulet / open door / west / remove amulet / close door / lock disturbing door with amulet / drop amulet / unlock disturbing door with amulet".
Daunting Dungeon
You can see a Disturbing Door here.

>(Testing.)

>[1] unlock disturbing door with amulet
You unlock the Disturbing Door.

>[2] open door
You open the Disturbing Door.

>[3] west

Fallow Field
You can see a Disturbing Door here.

>[4] remove amulet
You take off the Amulet of Tumblers.

>[5] close door
You close the Disturbing Door.

>[6] lock disturbing door with amulet
You lock the Disturbing Door.

>[7] drop amulet
Dropped.

>[8] unlock disturbing door with amulet
(first picking up the amulet)
You unlock the Disturbing Door.

For a more systematic handling of the keychain problem (and a number of other refinements to the behavior of doors), see the Locksmith extension included with Inform.