Slogar's Revenge
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.
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":
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".
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.