Responding to which vocabulary was used for an object

I want to have (slightly simplified example) an object representing a pile of blocks with different properties. So, for example, the player should be able to type EXAMINE SMALL RED BLOCK and get a message saying “You choose one of the small red blocks to look at” or similar (and I want to special-case some of these; for example “You choose one of the small white blocks - and it turns out that it’s actually an ice cube!”).

In I6, I know I could write a parse_name property which records which vocabulary words were used to refer to the object and then does whatever logic I want based on that. Having searched the I7 documentation, I can’t find anything which exposes something similar to this. Does anyone have any pointers to get the effect I’m looking for?

For something like this I’d probably sub out the description of the object (either with an instead rule or a to-say routine or something like that), and then you can use conditions like:

if the player's command includes "red":
1 Like

Maybe something like this (to be tuned to avoid default parser messages and to avoid default listing contents) ?

Lab is a room. "You see a pile of blocks in various colors and sizes."

The pile of blocks is in the Lab. The pile of blocks is a container.

A small red block is a thing. It is a part of the pile of blocks.
A large red block is a thing. It is a part of the pile of blocks.
A small white block is a thing. It is a part of the pile of blocks.

Understand "small red block" as the small red block.
Understand "large red block" as the large red block.
Understand "small white block" as the small white block.

Report examining the small red block:
	say "You pick one of the small red blocks to look at.";

Report examining the small white block:
	say "You pick one of the small white blocks - and it turns out to be an ice cube!";

Report examining the large red block:
	say "It belongs to Monsieur HUT, so drop it immediatly.";
1 Like

I’m always super suspicious of using the whole text of the player’s command because of false positives like “put the red ball on the pile of blocks”. Is there any way to extract just the part of the player’s command that refers to the noun/second noun?

I’d like to have a large number of colours and other adjectives, so I’d really prefer not to create a distinct object for each one (this is part of a puzzle where the goal is to figure out which combination of adjectives is the correct one, so I need enough possibilities to deter the player from brute-forcing it).

Understood. What if you create cubes as duplicates but part of the big object, with a default value for the colour property, and then run a phrase to set colours from a huge list of colours from a table ?

I think you want the Subcommands extension! This exposes the snippets that were used to refer to each object in the command.

4 Likes

That looks like exactly what I wanted, thanks!

The one big weakness of this is that each object has only a single subcommand property, so if the noun and second noun are the same, you’ll only get the words from the second noun. Alternatives have been proposed using two global variables, but that means you can’t get the subcommands of multiple objects (TAKE RED, GREEN, AND BLUE PILLS).

If that becomes too much of an issue, make a second subcommand property.

2 Likes

I’m struggling to remember the last time I typed a command in a game where the noun and second noun were the same so I think I can probably live with it. And if I’m wrong you’ve told me where to look!

It doesn’t come up often; the main place it would come up is if, say, you have a “generic scenery” object with tons of synonyms, and use the subcommand to give meaningful messages for interacting with it.

1 Like