Inform 6: Help with NPC scope and such

So I’m wondering how to go about solving this problem. My intention for this scene is to have an NPC who is in one room, yet is visible from the room connected to it. He can talk to the player while the player is in either room, but the player can’t do anything but listen to/examine the guy unless the two are in the same room. Should the player attempt to walk beyond these two rooms, the NPC will force them to stay until he’s finished talking.

However, I’m pretty flabbergasted here. Like, do I use PlaceInScope(dude_who_talks_a_lot)? If so, is there a way to reliably place him in/out of scope upon entering/exiting the appropriate room?

Being a bad and unexperienced programmer, I would do it in a pretty unelegant way. First, since I gut no clue how to deal with connecting rooms, I’d place a scenery (yet animate) object in room 1 which is an optical copy of the NPC in room 2. Then, I’d give the NPC a daemon routine and nudge him so that he starts doing stuff although the player is not in the same room. In this daemon routine I’d reroute the output to room 1 in case the player is there. That should already do the trick. I know it’d be horrible spaghetti code, but it would work.

I think PlaceInScope is your best option. See section 32 of the Designer’s Manual as well as the solution to Exercise 100.

I can’t seem to get PlaceInScope to do what I want it to. In this case, I have it set up so that the main room (which has the NPC, Leon, in it) is connected to the second room, which has this bit:

each_turn [;
if (leon.arrived == true) PlaceInScope(leon);

and then have it so that his before and life routines intercepts any verbs besides Examine and Listen. But when the player walks into the connected room, they still hear him blah-blahing (because the daemon causes that to happen anyway), but if they try to “x leon”, the game says he can’t be seen. So, what’s the deal? Should I use a different method?

I did it slightly differently. I have an add_to_scope in each room that the NPC can be seen from. Then I block player actions except for examine (which varies depending on whether the NPC is in the same room as the player) in the NPC itself.

Look at the exercises in chapter 32. PlaceInScope() can only be called from the InScope() top-level function, or from add_to_scope property functions.

It doesn’t really give any help on this specific situation that I can tell. There’s clearly several things that I’m missing but I don’t have the foggiest idea what they are because I’m terrible at piecing together solutions like this. Is there a tutorial on this kind of thing I can look up, or maybe the source code of a game with a similar situation? Because I’ve gone over 32 several times and still can’t get this to work.