Changing what something is "understood" as to a list of multiple words?

Hi folks,
I’m trying to make a game involving objects that transform into copies of other objects and copy their properties, and I’m stuck on one part - the “understand [text] as [the object]” part. Specifically, I want to say something like

A swatch has some text called the extraColors. Understand the extraColors property as describing a swatch. 

And this works if I only have one piece of text (e.g. “the extraColors of swatch A is ‘Red’”), but not if I have multiple (e.g. “the extraColors of swatch A is ‘maroon/magenta/pink’”), even if I bundle them (e.g. “the extraColors of swatch A is [red]. Understand ‘maroon/magenta/pink’ as red”). Ideally, I’d like to define all these objects via a big table as well, which is why I’m using properties.

I’m sure I can find a hackier way to implement this, but I’d really like to do this as simply as possible - if anyone has a suggestion for how I can do this, or a bit of syntax governing understands that I missed, please let me know!

If you’re just trying to add synonyms for the base colors (i.e. red) then you almost have it.

Understand "magenta", "maroon", "pink" as red.

No need for the extra colors property.

I assume here that you want the player to be able to type, for example ‘take red’ and for this to match any swatch in scope that happens to have red as one of the alternatives in its extraColors property at the time.

For the parser to match things like “red/green/blue” in this way, it needs to be matching a topic, not a text. You can create a topic property, but unfortunately Inform won’t let you use that property in an ‘Understand the extraColors property as describing a swatch’ phrase- it admonishes you to use only simple properties in this way.

So, here’s a little subterfuge to allow it:

"Swatch" by PB

A swatch is  a kind of thing.  A swatch has a topic called colour-range.  A swatch has a text called selected-colour. Understand the selected-colour property as describing a swatch.

Lab is a room.

The scarf is a swatch in the Lab with colour-range "red/blue/green".
The cloth is a swatch in the Lab with colour-range "red/orange/green".

To retokenise: (- VM_Tokenise(buffer, parse); players_command = 100 + WordCount(); -).

After reading a command:
	repeat with target running through swatches:
		if the player's command includes the colour-range of target:
			[say "Match found to [matched text] [target].";]
			now the selected-colour of the target is the substituted form of "[matched text]";
	[say "The player's command is: [player's command]."]

It works by pushing whatever word the player typed to match the topic property of a swatch into a text property of the same swatch, which describes said swatch and is thereby recognised by the parser.

The VM_Tokenise thing is to correct a bug introduced in Ver 10 that interferes with the correct response to disambiguation questions- it shouldn’t be needed in Ver 9.3/6M62- or indeed the forthcoming version, when it is finally released.

EDIT: this simple scheme deals well with simple commands such as “take red”, including disambiguation if more than one partly red swatch is in scope, or ‘take all red’. It would need to be elaborated to elegantly cope under all circumstances with more complex commands such as ‘take red and green’ or ‘take red. take green.’


If you want multiple color words to match a single swatch, an alternative approach would be to use a relation to handle the various-to-various mapping of colors to swatches, similar to what’s described at Mr Socks is a pink and green knitted cat....


Yeah, that’s another neat trick that I considered, but it doesn’t so readily meet the brief of being able to easily define swatches’ colours as topics in a table and to very easily copy colours across from one swatch to another with, for example, now the colour-range of the handkerchief is the colour-range of the necktie

EDIT: On the other hand, my scheme has the disadvantage that colours don’t have any existence as anything other than arbitrary texts which are part of constant topics- i.e. compiled routines to match against a provided command text. So it’s not so easy to independently add/remove individual colours from the colour-range property. You can’t for example, given a green, white and blue handkerchief, write things like now the handkerchief is not coloured green, which would be possible if the colours were handled as a relation to colour-named things.

Getting this to work in 6M62 took a bit more tweaking. It appears that the 6M62 compiler incorrectly treats a declared topic property as a text when generating the object declaration in I6, so the <snippet> includes <topic> phrase won’t function correctly without help:

Table of Fabrics
swatch	colour-range (topic)
scarf	"red/blue/green"
cloth	"red/orange/green"

When play begins:
	repeat through the Table of Fabrics:
		now the colour-range of the swatch entry is the colour-range entry.

This initialization rule can operate on a table that is used to declare the swatches themselves in conjunction with Some swatches are defined by the Table of Fabrics.

1 Like