Hi again. I don’t have a lot of keys, in fact only one so far, but I’d be interested to know if there is a correct way to force specific key use rather than just using an instead rule.
As I say, this isn’t a current issue, but I can conceive of a situation where there’s a limited amount of turns to unlock a door and just saying “unlock door” would remove this tension if the program pulls the correct key automatically.
(with the dimpled key)
You unlock the BARN DOOR
What you want is a matching key for the door:
The matching key of the barn door is the barn door key.
Or whatever the name of your key is. Can also say “The barn door key unlocks the barn door” which is a nicer sentence.
Thank you for your response.
I have the key matched to the lock but it still automatically unlocks it. I wonder if, perhaps, this happens because there is only a single key in the game so far.
Strike my last, I misread what you wrote. Try putting another locked door in the game first. As long as the key is matched only to the door you want it to unlock, it should prevent the player from opening any other door with it.
Almost! You’re still giving Inform a bit too much credit, in fact!
By default, Inform doesn’t like to guess nouns if there’s any ambiguity whatsoever. If the player is carrying two or more objects, they don’t even need to be keys, it won’t guess—because it doesn’t know that the dimpled key is a better guess than a watermelon.
The Locksmith extension (by Emily Short) lets you change this behavior, though only in the direction of being more intelligent about guessing, not less. But for your specific situation, if you just give the player more than one thing in their inventory, the problem will vanish.
Ah, I see.
In that case they’ll almost certainly have more than one item in their hands when they get to this point. If not, oh well, it’s not really a key intensive game. I had my eyes on the future and the thought just occurred.