Any way to dynamically change what words are "Understand"-ed as referring to an object?

I have an object that I would like to dynamically change in complex ways, including the words that the player could use to refer to it. The following example shows roughly what I would like to do - it all works fine except the last line that attempts to change what Understand works for the object. In this simple case there are easy workarounds that are not dynamic (such as an “Understand … when”) but my real case is too complex for that method to easily work. Is there any way to do this?

A colour is a kind of value. The colours are red, blue, and green.

Table of colour morphs
colour	name
red	"red morph"
blue	"blue morph"
green	"green morph"

The player is in a room called the test room.

A morph is in the test room. The morph has a colour.

Every turn:
	Let the new look be a random colour;
	Now the colour of the morph is the new look;
	Let the new name be the name corresponding to the colour of the new look in the Table of colour morphs;
	Now the printed name of the morph is the new name;
	Understand the new name as the morph;

This should work:

Understand the colour property as describing the morph.

This is the most relevant example in 2.3 of the Inform Recipe Book, though some of the others might be interesting to look at too.


Thanks so much Mike, it works perfectly.

1 Like

You might also want to look at the more flexible but complicated solution suggested in this recent thread:

There’s also the more basic case when there’s only one or two alternative names:

Understand "green" as the morph when the colour of the morph is green.

(I wouldn’t do it that way in this case – understanding via property is better. But it may be useful in other situations such as the “paper” turning into the “secret document” after you’ve read it, as in the examples.)

Thanks Peter for the signposting to the very relevant stuff in the other thread. I was tempted by Gavin’s solution that allows the use of tokens defined using inform 6, because tokens would provide some nice flexibility, but I don’t think I can just cut and paste the i6 code and tweak without better understanding than I have, because in my real code I’m defining on the level of kinds rather than a single object, which I suspect would complicate the i6 code. But the “understand the X property as describing a Y” code works fine with kinds so it’s good enough for me for now.