Rule for determining unknown character

I recently downloaded Inform7 and I am creating a small game to learn the system. I want to say a line of text upon entering a room if a certain character is in the room and you haven’t met the character before. So I have the following:

After entering Office:
If Nurse is unknown:
say “Oh, good you’re awake.”

First it complains about the phrase “Nurse is unknown”. I have tried substituting unfamiliar and unmet. I still get the same error.

Also, I remove the second line. Whenever I enter the office, it doesn’t print the line of text.

I’ve searched the forum and the manual, including the recipes. I can’t seem to find the solution.

Thanks in advance.

Going to a room is not the entering action. ‘Entering’ is for things you can get inside of, which are themselves in a room.

Familiar/unfamiliar are in the very commonly used Epistemology extension by Eric Eve. It comes with inform, so include that to use those adjectives.

For the rule itself you’d want the going action instead.

After going:
   If the room gone to is the Office and the nurse is unfamiliar:
      Say "Oh good, you're awake."

This actually does bring up a good case where a DSL should make sense, though. The original attempt of “After entering Office” not only reads better, it actually makes more sense and is even internally consistent with a realistic world model. If a room is just a container – ultimately, even if not in Inform’s view – then why would entering a room be any different than entering a closet or a bathtub?

Put another way, “entering the closet”, “going into the closet” and “going to the closet” are all pretty much saying the same thing from a language perspective. (And Inform is trying to model natural language in a domain-specific way.) Likewise, “entering the Office”, “going into the Office” and “going to the Office” are also saying the same thing.

Blecki,
Thanks for the help. I don’t remember reading about the going action. Do you know off hand which section it’s in?

Thanks again.

I don’t know that it has any dedicated section in the documentation. Look for it in the index.

Ok, so I have updated my story to match the rules above and I am still getting an error about not recognizing unfamiliar. I will also need to say the room description in my ‘going’ action.

However I am wondering how does Inform know when to display the character’s description and when to display their name? Can I not use that?

If there is a ‘Writing a paragraph about’ rule for the character, it will run that when printing the room description. If not, it will appear in the ordinary ‘also there’ list.

Rule for writing a paragraph about the nurse:
   Say "Hellloow nurse!"

You could hook into that, but then your text will appear in the middle of the room description when a greeting like that should appear at the end of it (For that matter, hooking into ‘after going’ might make it appear before the room description which is worse… but I’ve only got a hack to deal with that. Someone else might have a good solution for it.)

To use unfamiliar, you need the right extension. Add the line ‘Include Epistemology by Eric Eve.’ to the beginning of your text, if you haven’t already.

As Blecki said, to take care of “unfamiliar” you need this line at the beginning of your source code:

Include Epistemology by Eric Eve.

Then “unfamiliar” should work.

The basic idea is that Inform doesn’t understand most adjectives like “unfamiliar,” “unmet,” or the like unless you define them with a line like “A thing can be familiar or unfamiliar. A thing is usually unfamiliar.” Then you have to write some code to determine when things become familiar. (See section 4.7 of the manual on defining new either/or properties.) The extension has all this code in it already, and using the “include” line essentially drops the code into your game.

For more stuff about the “going” action you might want to look at sections 7.13 and 7.14 of the manual. This tells you some things about how you can use phrases like “going to.”

The problem with the room description not printing is tricky. The issue is that you have used an “After” rule. As described in section 7.5 of the manual, when an “After” rule runs it cuts off the rules that usually print text in relation to the action. (Unless the “After” rule contains the phrase “continue the action.”) The part that describes exactly how this works is well buried enough in the manual that I can’t find it now, but if you look at section 12.2 of the manual, the rule that prints the description of the new room is a “Report” rule. So we can take care of that problem by turning the “After” rule into a “Report” rule:

Report going to the Office when the nurse is unfamiliar: say "The nurse says 'Oh good, you're awake.'"

If you’ve got more than one Report rule that applies, they will all run, and more specific rules run first. So this should print the text you want before the usual report going rule prints the description of the room you’ve gone into.

bukayeva is critiquing Inform rather than trying to help people who are learning it, so if you wish to try to learn it you might wish to ignore that post.

I wouldn’t be surprised if Matt’s example doesn’t work either. If it runs after the room description; the room description will have just marked the nurse familiar and the rule will not match. Try it with ‘when the nurse was unfamiliar’.

I really appreciate all of the help on this. I had the Epistemology extension included in my source already, but it wasn’t being recognized. So I have trimmed the source file to just the following:

[code]“Nurse Sample” by Badcock

Include Epistemology by Eric Eve.

The Hospital Room is a room. “Hospital room description here…”

The Office is east of the Hospital Room. “Office description goes here…”

Nurse is a woman in the Office.

[Option 1]
Report going to the Office when Nurse is unfamiliar:
say “Oh good, you’re awake.”

[Option 2]
After going:
If the room gone to is the Office and the Nurse is unfamiliar:
Say “Oh good, you’re awake.”;
Continue the action;
[/code]

Using either option 1 or option 1 outputs the phrase from the nurse before the room description, which is not really what should happen. I will keep searching through the manual for an answer.

Unless someone comes up with a better idea, this is what I do:

Show nurse greeting is a truth-state that varies. Show nurse greeting is false.

After going:
   If the room gone to is the Office and the Nurse is unfamiliar:
      Now show nurse greeting is true.

Every turn when show nurse greeting is true:
   Now show nurse greeting is false;
   Say "Oh good, you're awake."

This works because the room description will be printed after report going finishes (I think it may be the equivalent of a ‘Every turn when the location of the player was not the location of the player’ rule, not sure), but the every turn rules don’t run until everything else has finished.

One way of getting text to show up exactly where you want it is using custom things to say, like this:

Include Epistemology by Eric Eve.

The Hospital Room is a room. "Hospital room description here..."

The Office is east of the Hospital Room. "Office description goes here..."

Nurse is a woman in the Office. "The nurse is here, doing nurse-type stuff[maybe greet player].";

To say maybe greet player:
	unless the nurse is seen, say ". 'Oh good, you're awake', she says";

The strange use of periods is because periods affect line breaks. Allegedly you can control this using “run paragraph on” in select places, but this is a skill I have yet to master.

Edit: you don’t need to define a custom say phrase either, you can just do

Nurse is a woman in the Office. "The nurse is here, doing nurse-type stuff[unless the nurse is seen]. 'Oh good, you're awake', she says[end if].";

Ah, I didn’t catch that you wanted the line to run after the room description.

One thing I just noticed is that “unfamiliar” isn’t what we want at all – in the Epistemology extension, a thing is unfamiliar until we’ve examined it. For something that changes when we see the nurse in a room, we want “unseen.”

Blecki is correct that a “report” rule won’t work if it runs after a room description, but for some reason a “rule for writing a paragraph about” will record the nurse as “unseen” if we’re seeing her for the first time. So you could do this:

Rule for writing a paragraph about the unseen nurse when in the Office: Say "Nurse says hi."

As Blecki says, this will put your nurse text before any “You can also see a desk here” stuff you might want to print. This may or may not be the best thing to do. If you want to make sure that the nurse paragraph runs after the whole description, you may want to use an “Every turn” rule which runs at the very end of the turn, after everything involved in printing the room description. Then the nurse will have been set to “seen,” but you can use “if the nurse was unseen” as Blecki suggests to check if she was unseen at the beginning of the turn. You’d also want to make sure the nurse doesn’t show up in the “You can also see” list, which you can do using a technique from section 17.25 of the manual:

[code]“Nurse Sample” by Badcock

Include Epistemology by Eric Eve.

The Hospital Room is a room. “Hospital room description here…”

The Office is east of the Hospital Room. “Office description goes here…”

Nurse is a woman in the Office. A desk is in the office.

After choosing notable locale objects when the location is the office and the nurse is unseen: set the locale priority of the nurse to 0.

Every turn when the location is the office and the nurse was unseen: say “Nurse says hi.”[/code]

Pretty sure this isn’t going to work (as I tested it) because the “after” rule prevents the report rules from running. so the room description doesn’t get printed at all. (And since it’s “after going” anywhere, this will suppress all room descriptions after going.) You can add “continue the action” here, but then you still get “You can see the nurse here” before the nurse greeting; if you don’t want that you need to muck around with the locale priority.

The difference between this technique and the “every turn” rule I posted comes is that yours only fires when the player walks into the office and nurse is there, and mine would fire if the nurse gets moved into the office while the player is there. badcock can decide which s/he prefers; my guess is that, if it’s a simple game, the nurse is always in the office and it doesn’t make a difference.

One easy way to force a report going rule to run after the standard report going rules (and in general to force a rule of a given kind to run after any other rules of the same kind) is to explicitly tell it to:

Last report going to the Office when Nurse was unseen: say "Oh good, you're awake."
(Note that since the player sees the nurse as he walks into the Office, the nurses ‘unseen’ status changes to ‘seen’; so you need test whether she “was unseen” at the outset of this turn of the game rather than whether she “is seen” at the current stage of the game.)

We need some level of documentation to sit between the documentation and the recipe book full of stuff like this, where it just lists all the ways you can achieve something.

I have found using Example 379 Saint Eligius from the manual gives the results I am looking for. Now to just modify it for characters.

"Nurse Sample" by Badcock

Include Epistemology by Eric Eve.

The Hospital Room is a room. "Hospital room description here..."

The Office is east of the Hospital Room. "Office description goes here..."

Nurse is a woman in the Office.

The first look rule is listed after the room description paragraphs about objects rule in the carry out looking rules. A room can be commented or uncommented. A room is usually uncommented. 

This is the first look rule: 
	if the location is uncommented, carry out the gawking at activity with the location. 

Gawking at something is an activity. 

Rule for gawking at the Office: 
	say "Oh good, you're awake." 

After gawking at a room (called the target): now the target is commented. 	

Thanks everyone who has contributed to this discussion. I can say I learned a lot already, and there probably is more to learn from these examples than I currently know.

I have tried all of these ideas. I think right now I am leaning towards using the example Felix provided. Matt W’s example also worked well.