I7:NPC Frustration

Although I am a professional programmer, I have to say I’m struggling a bit with some aspects of Inform 7. I seem to be relying of random scatterings of examples, rather than having the clear syntax explained to me. Maybe I’m looking in the wrong place.

For example, as a test I’m trying to get a character to respond when you say the word “Hello”.

e.g.

Say Hello to Dave

“Hi Steve, how’s it going”. - Says Dave

I just can’t seem to get it to work though.

The closest example I can find is of the form “Instead of saying yes in the presence of…”

So I wrote this.

“Test” by Steve

The ballroom is a room. Dave is a man in the ballroom.
Instead of saying yes in the presence of Dave:
say “That was a bit non-sequitur.”

The code doesn’t actually work though. The response to saying yes is just…
(to Dave)
There is no reply.

Worse still, if I change yes to hello (which is the word I wanted), it won’t even compile. Clearly “yes” is a special word that I7 understands. But what if I want to process anything the player says. Surely it would make sense to be able to capture any word in a “Instead of saying” clause.

Also, I don’t really want Dave to just respond when I say “Hello” in his presence. There might be other people present after all. However, if I change the code to the very obvious line “Instead of saying yes to Dave:”, it refuses to compile.

Either the documentation to speaking with NPCs is lacking or I am really missing something in the manual.

The basic conceptual problem that I think you’re running into is that the conversation model for I7 is built lean and mean – you’re meant to extend the parser as you see fit, unlike say TADS 3 which has a more developed model.

However if you look at section 7.6, example 2, there are a couple of things to help you out:

[code]The Grove is a room. In the Grove is a woman called the Sybil.

Instead of asking the Sybil to try saying no: try saying no. Instead of asking the Sybil to try saying yes: try saying yes. Instead of asking the Sybil to try saying sorry: try saying sorry.

Instead of answering the Sybil that “yes”, try saying yes. Instead of answering the Sybil that “no”, try saying no. Instead of answering the Sybil that “sorry”, try saying sorry.

Instead of saying yes in the presence of the Sybil:
say “She looks interested.”

Instead of saying no in the presence of the Sybil:
say “She looks annoyed.”

Instead of saying sorry in the presence of the Sybil:
say “She looks bored.”

[The complexity arises from the fact that we want to handle both YES and SYBIL, YES. If we only had the latter, ‘yes’ would be treated as a text given to the Sybil, just as in the commands SAY YES TO SYBIL or ANSWER YES. But because we have defined it as a command (so that the player can use it independently), SYBIL, YES is understood as an order to the Sybil to do the YES action.

Fortunately, we can redirect everything, as here, so that the results wind up the same.

And if we want yet another variation not covered by the Inform standard:

Understand “tell [someone] [text]” as answering it that. Understand “tell [someone] that [text]” as answering it that.

But that is a matter for a later chapter.]

Test me with “yes / sybil, yes / say yes to sybil / answer yes / tell sybil yes / no / sybil, no / say no to sybil / answer no / tell sybil no / sorry / sybil, sorry / say sorry to sybil / answer sorry / tell sybil sorry”.

[/code]

Hope that helps.

Hmmm. I’ve figured it out.

Whenever you use the command “Say [word] to [person]”

The word can be captured using the following code.

Instead of answering [person] that “[word]”

So if you want to say Hello to Dave and have him say “Hi there”, the code is…

Instead of answering Dave that “Hello”, say “Hi There”

So when you say something to someone, it thinks you are answering them, since you have to use the “Answer” keyword to capture the words. I really think that should be more explicitly spelled out in the manual.

It works for sentences too.

e.g.

Instead of answering Dave that “How are you”, say “‘I[apostrophe]m fine.’”

Say How are you
“I’m fine.”

However, if you try to add in the question mark…

Instead of answering Dave that “How are you?”, say “‘I[apostrophe]m fine.’”

It doesn’t work. It does not recognise “How are you?” or “How are you”

However, if you change it to…

Instead of answering Dave that “How are you ?”, say “‘I[apostrophe]m fine.’”

Then it will recognise “How are you ?”, but you have to put the space in. Most people would not naturally type the space, so that is a bit annoying. It would seem that a question mark is a special character, but if that is so, why is it able to match it if a space is present?

Is this actually the best place to get Inform 7 questions answered or is there some official inform 7 forum?

Many I7 authors read the rec.arts.int-fiction newsgroup – more than those that read this forum I think it’s safe to say.

groups.google.com/group/rec.arts.int-fiction

There isn’t an official forum, but there are certainly I7 users (like me) hanging out here from time to time.

The newsgroup linked to above is a good place, as is the Inform 7 channel on ifMUD.

The quickest place – and the place where pretty much everybody goes regardless of what “other” forums/chats they use – is definitely the newsgroup.

I’m just happy the forum is seeing a bit more activity these last couple of days.