Nationality relationship

The recipe book mentions nationality as a many-to-one relationship but doesn’t give an example of it. I’ve been trying to make this work to my satisfaction but I’m doing something wrong.

Ideally, I want the player to say “examine Allurian woman” and get a sensible response or a disambiguation. I also want to be able to use the nationality in the code itself, to determine (for example) if there are any Gemnians in the room who might take offense to something the player does.

[code]A nation is a kind of value. The nations are Allor, Dasine, Gemnos, Magna Etolia, and Rhothes.

Nationality relates various people to a nation. The verb to hail from (he hails from, they hail from) implies the nationality relation.

A nationality-name is a kind of value. The nationality-names are Allurian, Dasinian, Gemnian, Magnar and Rhothian.

A person has a nationality-name called demonym. The plural of demonym is demonyms.

To decide which nationality-name is the demonym of (sample - a person):
if the nationality of the sample is Allor, decide on Allurian;
if the nationality of the sample is Dasine, decide on Dasinian;
if the nationality of the sample is Gemnos, decide on Gemnian;
if the nationality of the sample is Magna Etolia, decide on Magnar;
if the sample hails from Rhothes, decide on Rhothian;
decide on Gemnian.

Bob is a man from Testbed. Bob hails from Gemnos.

The description of Bob is “Bob is a[if the demonym of Bob is Allurian]n[end if] [demonym of Bob] man. He is from [nationality of Bob].”
This correctly prints the nationality — the name of the nation. It does not decide upon the correct demonym, defaulting to “Allurian.”

[rant]What happens if you change “If the nationality of the sample is Allor” to “If the sample hails from Allor” etc.? The way you’ve defined it, it doesn’t look as though “the nationality of” should make any sense, since “nationality” isn’t the name of the property of a person (you haven’t written “A person has a nation called nationality”). Untested, though.[/rant]

UPDATE: OK, I’ve tested it, and that’s not it. The problem, I think, might be that if you define “demonym” as a property of a person, you can’t use a to-decide phrase to set it. If you comment out “A person has a nationality-name called demonym. The plural of demonym is demonyms.” it seems to work.

Unfortunately, I think this might make it harder to understand “x gemnian” ultimately – I remember running into trouble with something similar before, but I don’t have time to look up the particulars now.

I had that also; it produced a similar effect.

Fixed. I removed the line establishing a demonym as a property of people, and it works just fine.

Edit: Thanks for your help. I think we did it concurrently. Now to understand the words as adjectives.

Yup – I just updated my original post with more info. [And while I was posting to say that, you updated to say you figured it out yourself.]

As far as understanding the name goes, unfortunately I don’t think the obvious solution works – see this bug report and this thread. Understand tokens are only allowed to search relations between things, so setting up a relation between a person and demonym and using a token like “[something related by demonymizing]” doesn’t seem like it’d work.

Someone might have a clever solution, but what I might try is deleting the to-decide phrase, putting back the line about “A person has a nationality-name called the demonym,” and then looping through persons when play begins to set their nationality according to their nation. Then I think you could use the line “Understand the demonym property as describing a person.” It wouldn’t handle people changing their nationality in the course of play, but maybe that won’t happen.

This thread discusses how to understand relations as adjectival forms of the objects they relate to:

This works beautifully. It asks for disambiguation (“who did you mean?”) when there’s more than one of that demonym in the room.

The only hiccup is that the player can say “examine magnar” (for instance) and get a description of himself. I can live with that, though.

The painfully obvious solution is simply not to assign the player a (known) demonym. I’ll do that.