Say things the first time something is seen?

I have been trying to get a piece of Inform 7 code I’m working on to say something when a person is seen for the first time. It’s not working.

The code:

The Party is a room. The printed name of The Party is "Party". 
In The Party is a man called The Detective. "The detective is a shady-looking man in a shady-looking suit."
If The Detective is seen for the first time: 
	say "There he is. (the guy's name). The man who's been after me for seven years."

That last sentence makes Inform throw an error. How do I get it to work properly?

That depends what you mean by ‘seen’. Normally I7 only uses ‘seen’ only in the context of which objects are presently in scope for actions (see 6.13), not a state of knowledge. To use ‘seen/unseen’ as adjectives describing whether the PC has ever seen an object, you probably want to use the extension Epistemology by Eric Eve.

That isn’t necessary for what you (probably) want, however; you can just tell I7 to only print that message once:

In The Party is a man called The Detective. "The detective is a shady-looking man in a shady-looking suit.[first time]There he is. (the guy's name). The man who's been after me for seven years.[only]"

Also, be careful as to whether you want to put the text in the detective’s description or his initial appearance – see section 3.11 for the difference. Text in quotes after the detective’s name is the initial appearance and will be printed whenever the room description is printed, in response to “look” or whatever – you might not want “The detective is a shady-looking man in a shady-looking suit” to show up in the room description. If you want some text to be in the detective’s description, which is what you get when you type “x detective” you need to write “The description of the detective is…” and then your text.

[I presume you’re Jane Narbon from the Shaenon Garrity forums? Welcome! I mostly lurk there but I did do the [url=http://www.webcomicsnation.com/shaenongarrity/skinhorse/series.php?view=archive&chapter=43857]NetHack fan art[/url].]

Yep, that’s me! Me and another member are working on a spy story. Nice to be recognized! :slight_smile:

Thanks for the tips— I’ll try those.

To expand on Mr. maga’s response, the reason you want to make the supplementary text a feature of the detective’s description text is twofold:

1. If you’re checking whether the detective has been seen (via the Epistemology extension), the detective will almost certainly show up in a list of room contents prior to the player trying the “examine” action on him. This will cause him to be flagged as seen before the first time that his descriptive text is printed, so the alternative description will never be displayed by the player.

2. Tying it to the “examine” action is also problematic, because it’s possible that examining might fail due to some overriding condition. A failed attempted at examining will still flag the detective as “has been examined” (albeit unsuccessfully), so you’re back in a situation where the alternative description will never be displayed.

Mr. maga’s solution makes the alternative description contingent upon printing the description of the detective for the first time, which avoids both of the preceding issues. However, this does introduce another potential glitch: if the detective appears in multiple contexts, it’s possible that the player won’t ever get around to trying “examine detective” during their first meeting. This could cause the alternative description to pop up much later in the story, at a point where it’s no longer appropriate or relevant, if that happens to be the first time the description of the detective is successfully printed.

Actually, that text is the initial appearance of the detective, not his description. It’ll print after the room description when the player is in the same room as the detective. (I7 is a bit weird about the text-immediately-following-an-object-declaration thing; it’s the description of a room, but the initial appearance of a thing or a person.)

Ah, true. That does reduce the probability of the first case I outlined, though it doesn’t preclude it entirely (i.e., the detective could hypothetically end up in scope for the first time prior to the player first viewing the description of the room he’s in).

This is exactly what I was looking for. The included examples use a custom-defined “unexamined”/“examined” rule, which somehow seems to conflict with effects that happen “After examining the noun”, such as changing the printed name of an object. The two together (variable descriptions with varying display names) are part of the core experience I really enjoyed from the point-and-click era.

That said, if anyone has a better/cleaner solution for combining the two effects, I’m all ears.

Actually, the initial appearance is only displayed at the end of a room description. And the way text formatting tags like [first time][only] work is tied to each block of quoted text – if the detective is referenced or placed in scope at some point, but the initial appearance is not shown, that one-time text will not actually be displayed (let alone skipped over) until that happens.

“The Detective”

a thing is either seen or unseen.
a thing is usually unseen.
after examining something for the first time:
now the noun is seen.

Party is a room.

a man called The Detective is in Party.
the description of the Detective is
“The detective is a shady-looking man in a shady-looking suit.”

instead of examining the detective for more than the first time:
say “There he is. (the guy’s name). The man who’s been after me for seven years.”