"Unlocking" Bug?

Inform 7 appears to be treating lockable items as keys! Which is creating some very strange results.

Here is a test project I created;

When I try to ‘open’ the chest I quite correctly get;

open chest
It seems to be locked.

but when I try ‘unlocking’ it when the pass card is not in the inventory or in the same room I get;

unlock chest
(with the chest)
(first taking the chest)
That’s fixed in place.

It’s trying to unlock the chest WITH the chest! WHY!!! Aaaarrrggh!

I don’t think it’s any of my extensions, this happens in a new project with no other source.

It’s not a bug, it’s just that there’s only one non-scenery object in the room, so the parser assumes that.

(The grammar doesn’t prohibit “unlock chest with chest”, because it’s better to parse an action and respond with a failure than to fail to parse it at all.)

In a non-test-case game, you’ll almost never see an “unlock chest with chest” assumption because there will be more objects around. (If the player is carrying exactly one thing, the parser will assume that. If you create some more objects in the room, or if the player is carrying several things, the parser will ask instead of assuming.)

Does that code really compile? :open_mouth:

@zarf Thanks, so it IS a bug, but there’s a way round it. So this is a good reason to have items which must be carried to leave certain areas, to bulk out the inventory.

@Jamespking Has anybody ever set a whole adventure in a single room?

ifdb.tads.org/search?searchfor=tag:one-room
ifdb.tads.org/poll?id=cihcbyq1ucp6cqu6
ifdb.tads.org/poll?id=w20yzxhrzx5f7bry

I wouldn’t call it a bug, anyway, it’s just default behavior that works in a fairly clumsy way. This is one case where Inform provides a pretty easy workaround, as described in section 17.30 of the documentation:

Understand "unlock [something]" as unlocking it with. [You need this line so the game goes to your supplying a missing second noun rules instead of trying to disambiguate it by hand] For supplying a missing second noun while unlocking: if the player carries the pass card: say "(with the pass card. You're welcome, Jenni)[command clarification break]"; now the second noun is the pass card; otherwise: say "You don't have anything that unlocks anything."

And you could change this in various other ways to produce different behaviors, such as for instance not including special messages to Jenni, though I’m sure she would appreciate it.

That depends. One person’s bug is another person’s feature. You can get a more reasonable message just by adding the locksmith extension to your code, like so.

[code]“Test”

Include Locksmith by Emily Short.

The Lab is a Room. The description of the lab is “This is the lab.”.

The chest is in the lab. The chest is an enterable, fixed in place and locked container. [The lockable, openable and closed properties are set by default for a locked container or door.]

The Store Room is west of The Lab. The pass card is in the store room. The pass card unlocks the chest.

Test me with “unlock chest / w / take pass / e / unlock chest”.[/code]

Hope this helps.