Checking whether player has spoken to NPC


#1

I would like to test whether or not the player has spoken to a particular NPC before the player leaves a given room. Something like:

The Winged Otter is here. "His tophat is dapper."
Instead of going south:
	if we have not spoken to the winged otter:
		say "The winged otter flaps down to block your path, doffing his dapper tophat to you each time and extending a soft paw to shake.";
	otherwise:
		continue the action.

The code above does not compile, complaining that “In the sentence ‘if we have not spoken to the winged otter’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘we have not spoken to the winged otter’.” I tested the same setup with a different condition, simply

if we have not examined the winged otter

and that seems to work, so I’m fairly sure the problem is that I’m not referring to the speaking action in a way Inform 7 understands. How should I re-phrase this?


(Hanon Ondricek) #2

You can manually set up an adjective:

[code]
The Winged Otter is in The North Pole. “His tophat is dapper.”

The Winged Otter can be hat-tipped.

Before going south in The North Pole:
if the winged otter is not hat-tipped:
now the winged otter is hat-tipped;
say “The winged otter flaps down to block your path, doffing his dapper tophat to you each time and extending a soft paw to shake.”;
stop the action;
otherwise:
continue the action.
[/code]I think Before rules continue automatically. If so, you don’t need the last two lines but they won’t hurt anything.]


(Daniel Stelzer) #3

The key here is, the action has to be exactly one of the action names Inform recognizes. You’ll notice that “if we have not looked at the winged otter” doesn’t work, even though LOOK AT and EXAMINE are the same in play.

Try using the ACTIONS command in the game, then do whatever it is you want to detect, and Inform will tell you the internal name to use.


#4

Yeah, off the top of my head I’d use an adjective, as HanonO says. Although I’d probably do it more like this:

[code]The Winged Otter is in The North Pole. “His tophat is dapper.”

The Winged Otter can be hat-tipped.

After speaking to the Winged Otter for the first time:
now the Winged Otter is hat-tipped.

Before going south in The North Pole:
if the winged otter is not hat-tipped:
say “The winged otter flaps down to block your path, doffing his dapper tophat to you each time and extending a soft paw to shake.”;
stop the action;
otherwise:
continue the action. [/code]

I haven’t tested this, it’s just about making sure that the flag to allow the game to proceed ends up attached to the action of talking, or you could just try again to go south without getting your info out of him.


#5

What makes this more complicated that, say, checking whether we have examined something, is that Inform doesn’t have a single “talking” action. It has several: asking it about, answering it that, telling it about, asking it for.


#6

True. I had a “talking” action in the last game I did (which sometimes redirected to asking or vice versa) but that could probably be handled by “Asking the Winged Otter about is conversing. Talking to the Winged Otter is conversing.” etc. right?


#7

cool, thanks for the advice!

Here’s what I wound up with:

A Winged Otter is a kind of person. 
Nuvi is a Winged Otter.  Nuvi is here.  Nuvi can be hat-tipped.  "His tophat is dapper." 
After answering Nuvi that "hello" for the first time:
    now Nuvi is hat-tipped;
    say "The Winged Otter beams at you.  'Hello, there Human!  My name is Nuvi.'"
Instead of going south in the Atrium Glade:
	if Nuvi is not hat-tipped:
		say "As you try to move away, the winged otter flaps down to block your path, doffing his dapper tophat to you and extending a soft paw to shake.";
	otherwise:
		continue the action.

Which works a treat.
Now I’d just like to modify two things:

  1. I’d like to accept multiple greetings (e.g. hello, Hello, heLLo, yo, hiya…)
  2. I’d like to disallow movement in any direction, not just South

#8

Just a little note (a bit irrelevant to the rest of the conversation). If you write:

The Winged Otter is in The North Pole. "His tophat is dapper."

… you get:

…without the “Winged Otter” being mentioned in the room description. This is because you have assigned “His tophat is dapper.” as the “initial appearance” property for the Winged Otter.


(Hanon Ondricek) #9

You’re going down a cri-zazy path of allowing such random responses (camel case!) but you can group different phrases into a token like this:

Atrium Glade is a room.
A Winged Otter is a kind of person. 
Nuvi is a Winged Otter.  Nuvi is here.  Nuvi can be hat-tipped.  "His tophat is dapper." 
After answering Nuvi that "[hello]" for the first time:
	now Nuvi is hat-tipped;
	say "The Winged Otter beams at you.  'Hello, there Human!  My name is Nuvi.'"
Check going in the Atrium Glade: [note no specified direction]
	if Nuvi is not hat-tipped:
		say "As you try to move away, the winged otter flaps down to block your path, doffing his dapper tophat to you and extending a soft paw to shake.";
	otherwise:
		continue the action.

Understand "hello/Hello/heLLo/yo/hiya" as "[hello]".

Also note the parser does not pay attention to the player’s typed capitalization so Hello = heLLo = hello without specification when tokenizing (it might matter the first way you had it, but I’m not sure.)