I7: Understand "[nickname]" as John Doe.

I’m trying to have the game understand a nickname as a character. The code is something like:

[code]A person has some text called nickname.

John Doe is a male person in test place. The description is “He’s a tall fellow.”

When play begins:
let possible nicknames be {“Cactus”, “Spear”, “Pencil”};
sort possible nicknames in random order;
now nickname of John Doe is entry 1 from possible nicknames;
now the printed name of John Doe is “[nickname of John Doe]”.

Understand “[nickname of John Doe]” as John Doe.[/code]

This produces the error:

[code]Problem. I was unable to understand what you meant by the grammar token ‘nickname of John Doe’ in the sentence ‘Understand “[nickname of John Doe]” as John Doe’.

See the manual: 16.1 > Understand[/code]

Is there a way to do it? I’ve read the entire 16th chapter, but to no avail.

You can do it the explicit, one-by-one way:

Understand "Cactus" as John Doe when the nickname of John Doe is "Cactus".
Understand "Spear" as John Doe when the nickname of John Doe is "Spear".
Understand "Pencil" as John Doe when the nickname of John Doe is "Pencil".

If that would be really intractable, the Swedish Inform 7 translation extension includes code for understanding objects (of one’s choice) by their (current) printed name. It does mean a lot of indexed text manipulation, though, and, if used heavily, I think it will slow down parsing, at least on slow hardware.

If you define the nickname as indexed text rather than text, I think the following should work:

Understand the nickname property as describing a person.

Top notch, matt! Thanks.

Working code:

[code]A person has an indexed text called nickname.

John Doe is a male person in test place. The description is “He’s a tall fellow.”

When play begins:
let possible nicknames be {“Cactus”, “Spear”, “Pencil”};
sort possible nicknames in random order;
now nickname of john doe is entry 1 from possible nicknames;
now the printed name of John Doe is “[nickname of john doe]”.

Understand the nickname property as describing a person.[/code]

Kinds-of-value can also be understood. It seems arbitrary to me that texts can’t be understood, but KoVs can, but that’s the way it is.