intfiction.org

The Interactive Fiction Community Forum
It is currently Fri Feb 22, 2019 12:17 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Feb 10, 2019 2:17 am 
Offline

Joined: Mon Feb 04, 2019 6:52 pm
Posts: 2
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.

But firstly, the noun is nothing which I didn't expect. And I get errors such as
Code:
[** Programming error: tried to find the "." of (something) **]


Intuitively I would like to do
Code:
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.


Last edited by duke_meister on Sun Feb 10, 2019 9:40 pm, edited 2 times in total.

Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Feb 10, 2019 12:23 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5568
Location: Burlington, VT
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.


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!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Feb 10, 2019 8:08 pm 
Offline

Joined: Mon Feb 04, 2019 6:52 pm
Posts: 2
Quote:
place the contents of the other side of current in scope.


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

Quote:
Usually these rules are written as "after deciding the scope of the player"

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

Quote:
I think maybe you meant "current is open and..." not "or"?

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.

Quote:
Also I didn't test the code with Simple Chat

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

Thanks again!


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group