changing the name of a person depending on aquaintance

Hello again,

While writing my first project, I’ve stumbled upon another issue that I need to solve. I’m trying to implement a name change as soon as the player asks a person in the room about his/her name. As soon as the person is known it should be possible to refer to him/her with his/her name that the player now knows. Here’s what I got:

[code]A thing can be known or unknown. A thing is usually unknown.
Definition: a thing is unknown if it is not known.

The shop owner is a man. Understand “man” as the shop owner. The printed name of the shop owner is “the shop owner”.

Instead asking the shop owner about a topic listed in the Table of Conversation with the Shop Owner:
say “[Answer entry][line break]”.

Table of Conversation with the Shop Owner
Topic Answer
“name” “‘Well, my name is Herman Hercules. What is yours?’”

After asking the shop owner about “name”:
now the printed name of the shop owner is “Herman Hercules”;
now the shop owner is known;
understand “Herman Hercules” or “Herman” or “Hercules” as the shop owner.[/code]
However, Inform doesn’t recognize the last line. How should I change it in order for this to work?
Also, the printed name isn’t updated, he is still calles “shop owner”.

Thanks for your help!

I don’t think an “understand” statement can be put inside a rule. You could put it on its own line with a condition attached:

Understand "Herman Hercules" or "Herman" or "Hercules" as the shop owner when the shop owner is known.

I’m not sure about the other thing, and can’t test it at the moment. But what happens if you get rid of this line altogether?

The printed name of the shop owner is "the shop owner".

Here’s what you do:

[code]
A thing can be known or unknown. A thing is usually unknown.
Definition: a thing is unknown if it is not known.

Instead asking the shop owner about a topic listed in the Table of Conversation with the Shop Owner:
say “[Answer entry][line break]”;
continue the action. [‘instead’ stops the action by default; we need to directly tell Inform to continue the action, so that it gets to the ‘after’ rule]

Table of Conversation with the Shop Owner
Topic Answer
“name” “‘Well, my name is Herman Hercules. What is yours?’”

After asking the shop owner about “name”:
now the printed name of the shop owner is “Herman Hercules”;
now the shop owner is known.

Understand “Herman Hercules” or “Herman” or “Hercules” as the shop owner when the shop owner is known. [see bg’s post and 17.17]

The shop owner is proper-named. [so that we don’t see ‘you can see a the shop keeper here’ or ‘you can see a Herman Hercules here’][/code]

On second thought–you could also leave the condition off the understand line, since it’s pretty unlikely a player will refer to the character by name if the player doesn’t know the name yet. (And if the player does know the name from a previous playthrough, it might be annoying if the player tries to refer to the character by name but the parser doesn’t accept it.)

Aha! Thanks for the hints!
Well, it kind of works but I have the problem, that the shop owner seems to be recognized as a thing and not as a person. I wrote The shop owner is a man. But I get the standard message On the wingchair is a shop owner.
I also get problems with using the printed name of the shop owner: I want to use phrases such as Say "[The printed name of the shop owner] takes off his glasses and stares at you." but if I define a printed name of the shop owner, Inform doesn’t use the name with the right articles or capitalization. If I just leave out the printed name (and define it later after he is asked about his name) he is referred to with the indefinite article. Is there a way to say something like “If something is known, use definite articles in all contexts.”?
Oh and if I add a “continue the action” to the asking process, I always get the message “There is no reply.” However I can write something like Carry out asking the shop owner about a topic listed in the Table of Conversation with the Shop Owner: say "[Answer entry][paragraph break]". which works.
Yet ANOTHER problem: as soon as I have asked the shop owner about his name and he is known, I get the message “There is no reply.” after the asking process. When I ask about something before asking about the name, I don’t get this message. What’s wrong here?

@bg: yes, you are right but typing “Ask about name.” isn’t that long of a command. Besides, I want to keep it really logical, so I don’t plan to allow the player to address the man with his real name unless he asks about his name.

P.S.: Please be patient with me over the next month or so - I’m learning but I only need these hints once. :wink:

From earlier:

You don’t need this definition. You’ve already said that states of the either-or property are called “known” and “unknown” in the line above it.

He’s a person, but he’s improper-named, because you used the definite article instead of giving him a name like Bob.

An easy way to deal with this is to set the indefinite article to “the” instead of its default “a/an”.

Ye Olde Shoppe is a room. "This shop contains some old furniture, most notably a wingchair."

The wingchair is an enterable scenery supporter in Ye Olde Shoppe. 

The shop owner is a man on the wingchair. The indefinite article is "the".

You’ll want to make him proper-named when you change his printed name to a proper name.

You want:

say "[The shop owner] takes off his glasses and stares at you."

The printed name of the shop owner is a text, not a thing, so I7 will just print it. It won’t adapt it with articles or capitalization.

It sounds like you need to solidify your understanding of the stages of action processing (before, instead, check, carry out, after, report) and which ones stop the action by default vs. which ones continue the action by default. See §12.2. How actions are processed.

“There is no reply” is produced by a report rule in the standard rules. If you’re seeing it, then your code is allowing processing of the asking it about action to reach the report stage.

I’m not sure about your “Yet ANOTHER problem” without seeing your code. Are you blanking out table rows after using them? If so, then “topic listed in the Table of Conversation with the Shop Owner” might not apply the second time around after the shop owner is known. (I’m not a fan of the blanking out technique. I prefer to leave the entries in the table and add a boolean flag to each row if I need it. That way, the code still has access to the information that was in the table, and it can distinguish between something that was used and something that was never present.)

If that’s not it, you might try turning on rules debugging (toggle it with “rules”/“rules off”) before asking the shop owner about things. You’ll see which rules apply and in what order.

Edit: Added report to my parenthetical list of action processing stages.

Another possibility is if you have a rule like this:

After asking the shop owner about "name" when the shop owner is unknown: [stuff]

“After” rules by default stop processing the action whenever they run, so they preempt the “Report” rules. It’s a “Report” rule that prints “There is no reply” (if I remember correctly). So if your After rule stops running once you know the shopkeeper’s name, there’s nothing to preempt the Report rule, and you’ll get “There is no reply” again.

(This also might be why “continue the action” got you the “There is no reply” message–when you put “continue the action” in an After rule it won’t stop processing the action, which means it won’t preempt the Report rule.)