[I7] Different responses for trying to open a container with certain items

Oh boy, here we go.

There is an unmoveable container that needs an item in order to be opened. There are currently two items and only one of them will work to open the container. How do you print different responses for the items?


Could you explain how the item is to open the container? Is it a key for a lock which you want to distinguish from another?, something the player needs to be holding in order for an item to be opened, or something else?.

If it’s a matter of keys, simply declaring the key which unlocks the container will be enough to single it out. If you want to provide a specific message for some other key, you could do something like:

The black box is a closed openable locked container.

The silver key unlocks the black box.
The gold key is carried.

Instead of unlocking the black box with the gold key:
	say "It's the right size, but all it does is chatter around in the lock."

If it’s a matter of the player needing to have something before a container can be opened, I’d use a check-rule to stop the container from being at all openable before the player has the item, and then an after-rule to indicate success when the player tries the right action.

Void is a room.

The chest is a closed openable container in void.
The wand of strength is a thing in void.

Check opening the chest:
	if the player does not carry the wand of strength:
		say "You try and you try, but the lid doesn't move."

After opening the chest for the first time:
	say "You feel a strange humming sensation travel through the wand of strength, up your arm, and settle in your chest and shoulders.[paragraph break]With a harsh growl of rotten wood and rusted iron, the lid of the chest rises."

The “…for the first time” part is a good idea, so the message doesn’t become Repetitive. Subsequent openings of the chest will print your default response for successfully opening containers.

If none of this is useful to you, feel free to ask questions, or post code examples.

I have a panel that the player has to unscrew, but I’m using the lock/key system to do that. They have a screwdriver that doesn’t work and a penny. I want the player to be holding the penny to unscrew the panel, and the screwdriver to give a response about how it’s the wrong kind.

It’s possible to get what you want with the lock system, but there is a caveat. First, some code you can try, if this is the way you want to go:

Void is a room.

Understand the commands "screw" and "unscrew" as something new. [Synonyms of "turn".]

Understand "screw [something] with [something preferably held]" as locking it with.
Understand "unscrew [something] with [something preferably held]" as unlocking it with.

The tarnished panel is a thing in void. The tarnished panel can be locked. It is locked.
The panel is fixed in place.

The can't unlock without a lock rule does nothing when the noun is the tarnished panel.
The can't lock without a lock rule does nothing when the noun is the tarnished panel.
[Apparently saying some thing can be locked does not allow you to lock and unlock it, you have to tell Inform explicitly that this is allowed. You can remove the second rule exclusion if you don't intend for the panel to be locked again, but you'll need to write a message. An instead-rule will work.]

The player carries a screwdriver and a copper penny.

The description of the copper penny is "Scratched and tarnished. You see it was minted in the fanciful sounding year of 2012."
The copper penny unlocks the tarnished panel.

Instead of unlocking the tarnished panel with the screwdriver, say "That doesn't seem to work."

After unlocking the tarnished panel with the penny, say "Click!"

And there you have it, a panel you can pick with a penny. The problem I can see with doing it this way is you have sacrificed the primary grammar of your screwdriver to your penny. People generally expect a screwdriver to screw and unscrew, not a coin. I understand this is an element of your panel puzzle, but keep in mind that unless your screwdriver is a red herring (i.e., it never functions as a screwdriver in the game), it will have to be the matching key to something lockable if it is to work.

If that’s fine, you may want to implement some extra grammar for locking and unlocking (e.g. “pick”, “jimmy”) so that the player doesn’t have to do too much guess the verb. “Unscrew panel with the penny” is not so intuitive when you’ve been discouraged from using the screwdriver, the thing that actually screws and unscrews things.

If the screwdriver is going to be useful in another puzzle, or in the game in general, you may just want to go ahead and implement a screwing action and some logic for things to be, say, screwed/unscrewed, or tightened/loosened.