Apologies if this is something simple that I’m missing, but:
In Inform 7, it’s possible to have an object have a property (I believe that’s the appropriate terminology) that’s also an object. (In the vein of, say “A person has a supporter called the preferredBed”, or whatever)
I’m attempting to set up a system where there are glasses and beverages to put in them. For reasons related to other parts of the game, the beverages are defined as objects that are off-stage and have various properties. I want the player to be able to type, say “get water” to refer to a glass of water if there’s one available. The simplest version of the code I want is as follows:
[rant][code]A beverage is a kind of thing.
NotABeverage is a beverage. Water is a beverage. Milk is a beverage. Orange Juice is a beverage.
A beverageContainer is a kind of thing.
A beverageContainer has a beverage called the containedBeverage. containedBeverage of a beverageContainer is usually NotABeverage.
A glass is a kind of beverageContainer.
Printed name of a glass is usually “[If containedBeverage is NotABeverage]Empty glass[otherwise]Glass of [containedBeverage]”;
Understand the containedBeverage property as describing a beverageContainer.
The Bar is a room.
One glass is in the bar.[/code][/rant]
But the “understand…” line generates an error:
[rant]Problem. You wrote ‘Understand the containedBeverage property as describing a beverageContainer’: but that property is of a kind which I can’t recognise in typed commands, so that it cannot be understand as describing or referring to something. I can understand either/or properties, properties with a limited list of named possible values, numbers, times of day, or units; but certain built-into-Inform kinds of value (like snippet or rulebook, for instance) I can’t use.
See the manual: 17.15 > 17.15. Understanding things by their properties[/rant]
Having read through the recommended section in the documentation and not seeing anything directly related, I can only come to the conclusion that one of the following is true:
- Objects can’t be properties of other objects, and in fact are something else that behave like properties under some, but not all, conditions
- I’m using the wrong syntax to reference the property I want.
- Inform really doesn’t like the idea of using the names of objects to refer to other objects.
Anyone happen to be familiar enough with this sort of thing to give me a hint as to what I might be doing wrong? Thanks in advance.