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.

I happened across this thread, and even though it’s old, it presents a problem that’s easy to run into when using a kind of value instead of an object to represent properties of things. @Zed found a method that works well in this scenario.

Although it’s not spelled out in the documentation, a text property that is used for understanding can be dynamic, i.e. it can use substitutions instead of being a fixed string. Thus

A fluid container has some text called contained material. The contained material of a fluid container is usually "[type of substance of item described]". Understand the contained material property as describing a fluid container.

A fluid container has some text called presented colour. The presented colour of a fluid container is usually "[colour of substance of item described]". Understand the presented colour property as describing a fluid container.

will handle most of the issue. The caveat is that multi-word properties must be used in full in order to match, so given

In the laboratory is a fluid container called a flask. The substance of the flask is albumen.

then the commands >X CLEAR or >X THICK LIQUID will work as expected, but >X THICK will not, and >X LIQUID will be interpreted as the bowl of mercury only. As a result, it’s best to stick to single-word text values for any given property.

Multiple properties can work together, so >X YELLOW POWDER also functions correctly. It might be better to split out additional descriptors as their own properties, e.g. a viscosity column in the table to handle “thick” independently of “liquid”.

2 Likes