Two parsing questions:
First, is there a general technique for getting the parser to understand things based on the name of their kind when that is unambiguous? For example:
[code]The Lab is a room.
Rex is an animal. Rex is in the lab.
“x animal” produces “You can’t see any such thing.” Somewhat paradoxically, “x animals” works. Is there a way to make the former command work for Rex and any other animals I might care to create, without having to do an explicit “Understand” for each?
Second, related, question: How can I make this work?
[code]The Lab is a room.
A man can be rich or poor. Understand the rich property as describing a man.
Bob is a poor man. Bob is in the Lab.
Understand “pauper” as a poor man. [<---- Doesn’t work]
This still has the problem described above, i.e. that “x poor man” doesn’t work (“x poor bob” does). But I’d like to be able to do something with the same effect as the marked line, that is understand pauper as referring to a man if and only he has the “poor” property. Is it possible to do this without hacking the grammar for all of the individual verbs?
You can make an understand line to cover all instances of a kind:
Understand "animal" as an animal.
As for the second problem try this:
Understand "man" as a man.
Understand "pauper" as poor.
Thanks for the fast reply. The solution to the first issue seems obvious in retrospect.
As for the second, I may be being a little persnickety here, but doesn’t that mean that “x poor” will be accepted along with “x pauper” and “x poor man”? I know parser generosity in accepting free floating adjectives like that is something of a convention in IF, and I can live with it if the alternative is tinkering with low level parser stuff, but I was hoping for a way to treat poor as an adjective and pauper as a noun.
Yeah, it’s a convention, but for a good reason. If the story replies “You can’t see any such thing” when the player types “x poor” in the presence of a poor character, some people will think it’s badly implemented.
In any case if you want to disallow the adjective’s use out of context you can change it to
Understand the rich property as referring to a man.
Fair enough. But is there a way of solving the more general problem of understanding a word as referring to a particular object or kind if and only if a certain (possibly complex) condition is true. For example, understanding “clown” as referring to a person if and only if they are wearing a wig and a red nose and are in a tiny car.
Yes. Check out 4.14 in the documentation - Duplicates.
The example has code to distinguish differently-coloured and re-paintable children’s building blocks.
Also I think this would work:
[code]a person can be clownish.
Definition: a person is clownish if it wears a red nose and it wears a wig and it is inside a tiny car.
Understand “clown” as a clownish person.[/code]
You don’t need the first line, since the adjective is created by the Definition.
Definition: a person (called the subject) is clownish if the subject is wearing a wig.
Understand "clown" as a person when the item described is clownish.
The “when the item described is…” clause is the easiest way to tie an Understand line to an adjective.
Perfect. I thought I remembered that there was a construction to do what I wanted, but I couldn’t find it in the docs. Thanks all.