Examine scenery, place person

Hi,

I’m getting into writing my first IF game; a small detective story that let’s me muck about, write something (hopefully) fun and learn how this Inform 7 malakey works. So far I’ve managed to brute-force my way through any coding problems, but I’m stumped by this one, and figured maybe someone here would be able to offer some suggestions.

In my game, most NPCs aren’t readily available to talk to. You have to examine scenery, and then you take note of them. This is what I wrote to account for this, which has worked pretty well:

[code]An NPC is a kind of person. An NPC is usually scenery. Before examining NPC (called the target): Now the target is not scenery.

The gambling den is a room with the description “The den is a single open hall, packed with gamblers.”

Harry Balls is a male NPC in the gambling den with the description “[one of]The gamblers stare intently at their cards; a single older gentleman catches your eye.[or]An affable older gentleman reclines with his cards held almost disparagingly in front of him.[stop]” Understand “gambler”, “gamblers”, “approachable”, “approachable gambler” as Harry Balls. Harry Balls has the printed name “an approachable gambler”.[/code]

In conversation, he’ll give his name which will change the printed name to Harry Balls.

There are a couple of problems with this code. First off, what if the player wants to examine the other gamblers after Harry makes an appearance? Second, I don’t want the key to the walkthrough to be ‘enter the gambling den and type “talk to Harry”,’ when there is no Harry there. Without the step of finding Harry that’ll just seem really cheap.

So I’m trying to write a piece of code that will link an NPC to a piece of scenery; the NPC will be off-stage until the player examines the scenery, at which point he’ll be placed in the room.

I’ve tried a bunch of different ways of doing things, and here’s what I’ve got right now:

[code]NPC grabber is a kind of thing. NPC grabber has a person called designated NPC. An NPC grabber is usually scenery.

After examining the NPC grabber (called the target):
If designated NPC is off-stage:
Say “[paragraph break]A [designated NPC] catches your eye.”;
Move the designated NPC to the target.

Gambling den is a room.

Gamblers are an NPC grabber in the Gambling den with the description “The gamblers stare intently at their cards.” The designated NPC of gamblers is Harry Balls.

Harry Balls is a man with the description “yo.” [/code]

But that doesn’t seem to work. Can someone help me figure this one out, or show me how to write something that will do what I want?

A couple of thoughts (and I’m sure the people who really know will correct me):

With regard to your first block of code, I don’t think you can change the kind of a thing (from scenery to not scenery).

With regard to your second block of code, I think this basic approach may work. However, this form of “if” statement requires indentation for the various lines which are subject to the “if” condition. Also, you tried to move the designated NPC to the “target.” However, “target” is defined as the piece of scenery. I think what you need to do is move the designated NPC to the room which contains the target.

  Robert Rothman

You’re almost there. You just have to tell Inform exactly what designated NPC you want to move (viz. the designated NPC of the NPC grabber in question). Do this:

After examining the NPC grabber (called the target): if the designated NPC of the target is off-stage: say "[paragraph break]A [designated NPC] catches your eye."; move the designated NPC of the target to the location of the target.
You’ll also want to move him to the location of the gamblers (i.e. the gambling den) rather than to the piece of scenery that is the gamblers, or you won’t see him in the room when you LOOK.

Thanks for the help, guys! That worked like a charm.

It took a bit of iteration, but the code I use works perfectly fine. It’s not exactly what I needed, but I could see it being a useful trick in other situations.

Scenery isn’t a kind but a property, so you can switch it on and off during the game.

Thanks again for the help, guys. I just figured I’d show the updated version; the “A [designated NPC] catches your eye” line didn’t sit well with me, since it didn’t allow for any individuality in the first impression; which as anyone will tell you, is important!

So now my test game looks like this:

[code]“test” by Emanuel Nordrum

A person has a text called first impression. The first impression is usually “[the noun] catches your eye.”

NPC grabber is a kind of thing. An NPC grabber has an person called the designated NPC. An NPC grabber is usually scenery.

After examining the NPC grabber (called the target):
if the designated NPC of the target is off-stage:
say “[the first impression of the designated NPC of the target]”;
move the designated NPC of the target to the location of the target.

Gambling den is a room with the description “loads of gamblers here.”

Gamblers is an NPC grabber in the Gambling den with the description “description of gamblers”. The designated NPC of Gamblers is Harry.

Harry is an man with the description “Harry’s description.” Harry has the first impression “Harry’s first impression.”[/code]

Inform 7 can be really daunting when you get started, but I have to say, it’s incredibly satisfying to get these things working.

Of course, saying this, I’ve just realised that [the noun] calls on Gamblers in this example, not on Harry as it’s supposed to. [the person] doesn’t work, nor [the noun of the person]. Any suggestions?

For this kind of thing you want “[the item described]”; when you’re dealing with a property of something like its printed name or description, “the item described” gives you the thing you’re talking about. It’s like “the noun” for things that aren’t being called from actions, if that makes sense. [EDITED in a vain attempt to make that make more sense.]

Oddly, the “item described” token seems to be first documented in section 5.14, which is a review section, but it’s very useful.

Fantastic. I should have started asking questions weeks ago.