How to prevent Inform from providing a second noun?

My PC is only wearing “my clothes” and is carrying nothing else.
Inform automatically uses the PCs clothes as a second noun – how do I prevent it to do so?

>unlock the door
(with my clothes)

I tried to solve it with these rules

Before supplying a second noun:
    ...

Rule for implicitly taking my clothes:
    ...

They don’t throw an error but they don’t work either.
Am I using them wrong or is there just an other solution?

This works in earlier versions of inform. I know I didn’t consider using it for a while even though I used “rule for supplying a missing noun” a lot.

rule for supplying a missing second noun when unlocking:
  if number of keys carried by player is 0:
    say "You have no keys.";
    reject the player's command;
1 Like

Hi Andrew, thank you very much!
I tried it, but it doesn’t seem to work in my version (Inform 9.3 / 6M62).

1 Like

The choice of default noun was, and seems that still is, a weak point of either inform and/or Graham since, apparently, the days of Curses r7 and Inform 4, where EAT (or DRINK ?) can defaults to… a coal bunker !

Aschultz, I think that a keyring is a good candidate for an i7x… perhaps by Andrew Schultz ? :wink:

Best regards from Italy,
dott. Piergiorgio.

1 Like

Thanks Andrew, your solution gave me a new idea!
I now kind of hotfixed it with a new action:

Unlocking is an action applying to one thing.
Understand "unlock [something]" as unlocking.

It feels a bit dirty and not like the right thing to do, but I think it will do the job for now.

I’d be really interested in why your solution worked in earlier versions and why it doesn’t any longer.

2 Likes

As a very broad Inform guideline, creating a new action is usually the cleanest way to do what you want. In this case that is definitely true.

Btw, reject the player's command is documented only within the “reading a command” activity. But it’s just a custom spelling of rule fails, so you can use it in a lot of ways that have nothing to do with the player’s command.

3 Likes

The main issue here is that in order to trigger the ‘supplying a missing second noun’ activity, you need to have:

(i) a matching ‘Understand phrase’ that includes only one grammar token for an object (thing)
(ii) a corresponding action that is defined as requiring two things
(iii) have the player type a command that matches the ‘Understand phrase’ in (i) (with only a single object grammar token), but missing the second object required by the action.

In this case, the action ‘unlocking it with’ requires 2 things, but by default there is no Understand phrase matching only one object (the door)- the default solitary Understand phrase being:

Understand "unlock [something] with [something preferably held]" as unlocking it with.

which only matches when the player specifies both the door and the key.

It is not enough in this default situation for the player just to miss out typing the second noun. See WI 18.32 ‘Supplying a missing noun/second noun’.

In the default case, the above is the best-matching ‘Understand phrase’ for what the player typed when the player specifies only the door. Inform does try to guess what is intended as the key- with the help of any applicable ‘does the player mean’ rules but, somewhat counter-intuitively without looking at the ‘supplying a missing second noun’ activity.

However, if we add

Understand "unlock [something]" as unlocking it with

then this becomes the best-matching ‘Understand phrase’ if the player specifies only the door, and now Inform does trigger the ‘supplying a missing second noun’ activity.

So this should work, assuming that you want to have keys in your game at all:

Understand "unlock [something]" as unlocking it with.

A key is a kind of thing.

rule for supplying a missing second noun when unlocking:
	if number of keys carried by player is 0:
		say "You have no keys.";
	otherwise:
		[code to choose a key]

If you have no keys in your game, and you want locked things to remain locked, then you can just do

Understand "unlock [something]" as unlocking it with.

rule for supplying a missing second noun when unlocking:
	say "You have no keys.";
5 Likes

Thank you, that is very enlightening!