Objects referred to by value

In the following example, containers can have contents that are substances such as liquids and powders. The line “Understand the substance property as describing a fluid container” handily allows commands such as “take sulphur” to be interpreted as referring to the container.

The trick is that you should also be able to refer to a container by the properties of its substance, eg, “take yellow powder.” I can’t figure out how to do that.

[code]The laboratory is a room.

Colour is a kind of value. The colours are normal, white, clear, silver, yellow, red, and black.

Substance is a kind of value. The substances are defined by the Table of Substances.

Table of Substances
Substance Smell Colour Type
water “nothing” clear “liquid”
mercury “nothing” silver “liquid”
sulphur “a faint rotten-egg smell” yellow “powder”
albumen “nothing” clear “thick liquid”
none “nothing” clear “nothing”

A fluid container is a kind of container. A fluid container has a substance. The substance of a fluid container is usually none.

The description of a fluid container is “[if the item described is filled]A container filled with [the colour corresponding to a substance of the substance of the noun in the Table of Substances] [the type corresponding to a substance of the substance of the noun in the Table of Substances].[otherwise]An empty container.[end if]”.

Definition: a fluid container (called the current container) is unfilled rather than filled if the substance of the current container is none.

After printing the name of a fluid container (called the current container):
If the current container is filled:
say " of [substance]".

Understand the substance property as describing a fluid container.
Understand “of” or “full of” as a fluid container.

Rule for printing room description details of a fluid container:
stop.

In the laboratory is a fluid container called a bowl. The substance of the bowl is water.

In the laboratory is a fluid container called a bottle. The substance of the bottle is sulphur.[/code]

There are various ways. The easiest is

Understand “yellow”, “powder” as sulphur.

The weakness is that you can only use a given word once per kind-of-value. (If “liquid” is defined as a synonym for both water and mercury, it will only match water.) You can get around this to some extent with a line like

Understand “liquid” as a fluid container if the substance of it is water or the substance of it is mercury.

(HL has this problem in spades, obviously. I wound up defining two properties for a substance container: the substance itself, and a generic liquid/powder/paste property. Then I had to keep them in sync, which was no fun.)

Well, obviously I can do it in a case-by-case manner, but the whole utility of having a table is to avoid that (the entire table has 19 entries). I was hoping there was something like “understand the type corresponding to a substance in the table of substances as referring to that substance.”

The utility of having a table doesn’t include that, sadly.

You can define a custom relation (“The substance-type-linkage property relates a text (called X) to a substance (called Y) when X is the type corresponding…”) and use that in the Understand-line (“Understand “[something related by reversed substance-type-linkage]” as a substance.”), but it’s messy and will likely slow down your game somewhat.

Welp. List of synonyms it is, then.

Draconis,

Do you have a working code example of this? I would be interested to see it in action.

That exact code doesn’t work, I overlooked the fact that the “something related…” needs to be an object, not a text.

I tried this:

To decide what text is the substance-color of (item - a sample):
	let the element be the substance of the item;
	decide on the color of the element.

Understand "[text]" as a sample when the topic understood matches the substance-color of the item described.

But…

I’m reporting this on Mantis now, but I’m not sure if this would actually be valid anyway. Parsing for [text] in an item name is rather strange to begin with.