[solved] Talking to someone not in scope

Hi, new here, only been using Inform for a week.

I’m trying to use Simple Chat by Mark Tilford. But I need to bee able to talk to someone on the other side of a door. I’ve tried this:

[code]Talking to is an action applying to one visible thing.
Understand “talk to [someone]” as talking to.
Report talking to: say “You have nothing to say.”.

Before deciding the scope of the player when talking to:
repeat with current running through doors in location:
if current is open or the noun is on other side of current:
place the noun in scope.[/code]
But firstly, the noun is nothing which I didn’t expect. And I get errors such as

[** Programming error: tried to find the "." of (something) **]

Intuitively I would like to do

before deciding the scope of the player when talking to someone:

but then the Before doesn’t run.

What’s the right way of doing this? Thanks.

Welcome to the forum duke_meister!

“The noun” is only going to be set once the parser has interpreted the command, and the parser has to figure out the scope of the player before it can interpret the command, so that’s why the noun is nothing when you’re doing that. The way to think of it is like this:

In a command like “TALK TO BOB” the parser has to match the word “BOB” against the “[someone]” token. The way it does this is to take the things in scope and see if “BOB” can be understood as any of them. So what we want to do is not place Bob in scope–the parser doesn’t know what “BOB” means yet–but to expand the number of things that the parser will check against the word “BOB.”

So the logic you want is that you want to put everything on the other side of “current” in scope. If Bob is one of those things, then the parser will be able to find Bob. Fortunately, there’s a quick way to do that–if we “place the contents of [some room] in scope” it will put everything in that room in scope in one fell swoop. (“Place foo in scope” also places the contents of foo in scope by default, but in this case we don’t necessarily want to place the room itself in scope, as players can’t usually refer to rooms in their commands.)

So we can do this;

[code]Talking to is an action applying to one visible thing.
Understand “talk to [someone]” as talking to.
Report talking to: say “You have nothing to say to [the noun].”.

After deciding the scope of the player while talking to:
repeat with current running through doors in location:
if the other side of current is a room: [checking for deadend doors]
place the contents of the other side of current in scope.

Central room is a room. Eastern room is a room. Western room is a room. Southern room is south of Central room. Southwestern room is west of southern room.

The oak door is a door. It is east of Central room and west of eastern room.
The maple door is a door. It is west of central room and east of Western room.
The steel door is a door. It is north of southwestern room and south of western room.

Alice is a woman in Eastern room. Bob is a man in Western room.[/code]

Another couple of notes:
Usually these rules are written as “after deciding the scope of the player”–that all takes place before parsing so it’s fine. I’m not sure whether doing “before” makes a difference. But you need to say “while talking to” instead of saying “while talking to someone”–at this point the noun isn’t set, so you aren’t actually talking to someone yet!

“The other side of current” is a room. You don’t want to say “on the other side of current” because that will check whether something is on the room, in the way it can be on a supporter, and that will always be false. If you’re doing that check you probably want to check “enclosed by the other side of current”; “in the other side of current” would be only things directly in the room, not things on supporters in the room etc. (But you don’t actually need this, since placing the contents of the room in scope takes care of everything.)

I didn’t include any logic about the door being open. I think maybe you meant “current is open and…” not “or”? Anyway, if you want to restrict it to open doors, you can make the loop run through “open doors in location.”

Also I didn’t test the code with Simple Chat, so I’m not sure if it works with that!

Thanks. I like it, that did it. Happy that I was kind of close. Understand about the noun not being available at the time.

Strange but in my code it is after, but then again I wasn’t sure which way to go.

I see now the logic around being an open door is kind of irrelevant. I want to be able to talk to an NPC whether or not the door is open.

Yes my questions was not really related to Simple Chat, was just giving some context. ed: but it seems to be working fine :slight_smile:

Thanks again!