Matching types of value, and talking subjectlessly

Hiya! It’s annoying me that I can’t get “talk to [someone]” to produce “What do you want to talk to [the noun] about?” the way I can prompt a parser clarification rule for physical objects in the room, so I’ve been trying to circumvent this in a kludgey way with Mike Callaghan’s Questions extension…

Talking subjectlessly is an action applying to one thing. Understand "talk to [someone]" as talking subjectlessly.

Instead of talking subjectlessly:
	say "What do you want to talk to [the noun] about?";
	now current prompt is " ";
	now current question is " ";
	now punctuation removal is true;
	ask a closed question, in text mode;
	
A text question rule:
	repeat with N running from 1 to the number of rows in the Table of Conversation:
		choose row N in the Table of Conversation;
		let temp be "[topic entry]";
		let temp2 be "[current answer]";
		if temp matches temp2:
			say "[response entry]";
			exit;

The reason for this wordiness in the text question rule is to obtain a situation where the two things to be matched are the same kind of value, because Inform kept telling me that it couldn’t compare them. Now they are both “a temporary named value, holding a text” and the parser still can’t check if they match?

Better solutions for this problem are, of course, accepted - if I can’t sort it out quickly I’ll just have to make the player re-type “talk to X about spaghetti”…

As the error states, if x matches y is only valid for the following cases:

  1. (value) matches (description of values)
  2. (snippet) matches (topic)

Neither of those is the case. I7 has three different kinds of text values – a “snippet” is a set of words from the player-entered command, a “topic” is a thing that can be matched against a snippet, and a “text” is anything else. You can convert either of the first two to text, but you can’t convert them back again.

While there would have been a snippet in the input at some point, it looks like Questions passes the answer only as text, so you’re going to have to compare the values as text instead. You need a slight variation on the matching phrase to do that, but you can also simplify a bit more:

Instead of talking subjectlessly:
	now current prompt is "Topic? ";
	now current question is "What do you want to talk to [the noun] about?";
	now punctuation removal is true;
	ask a closed question, in text mode;
	
A text question rule:
	repeat through the Table of Conversation:
		if current answer matches the text request entry:
			say "[response entry][paragraph break]";
			exit.

(The other important change was to call the column in the table request rather than topic. Calling a column topic tells Inform to treat it as a topic instead of as text, and you don’t want that in this case.)

Note that if your story asks more than one kind of question then you may need to include some additional logic to only use these answers in the correct context.


A slight improvement is to make this an open question instead – this behaves more like a disambiguation question, where the player is allowed to either answer the question or to abandon the idea and try a different command instead:

Instead of talking subjectlessly:
	now current question is "What do you want to talk to [the noun] about?";
	now punctuation removal is true;
	ask an open question, in text mode;

You also might like to look into some of the existing conversation extensions – most of them do include solutions for talking subjectlessly already.

The code you suggested won’t compile with the existing “Instead of asking NPC about a topic listed…” - will I also have to change how the “ask person about topic” action works?

Also, am I understanding correctly that the suggestion of an open question is to make this a little better/more elegant/more friendly in general, but isn’t intended to solve this particular problem?

Any recommendations for a conversation extension? With my current time constraints, it might be something I investigate another day, but it’ll be good to know.

You didn’t include that code in your post, so I don’t really know what you’re referring to.

Correct, it’s an improvement on the design, not a fix in itself.

I’ve never really written a story with conversation myself, so I don’t have any experience with the extensions, but the two major ones that I’m aware of are:

  • Threaded Conversation by Chris Conley
  • Conversation Framework/Package by Eric Eve

You can find both of these (and their dependencies) at the extensions github.

Sure.

Instead of asking NPC about a topic listed in the Table of Conversation:
	say "[response entry]";

(using the built-in “asking it about” action)

Yeah, that does require the column be specified as a topic, since asking about does match a snippet against a topic.

The cheesy way to make that work is to define both the topic and request columns in the table, giving them the same content.

Otherwise it’s possible (though less efficient) to rewrite the above rule to convert the snippet to text before comparing it the same way as the other rule, but I don’t really recommend that.

Having duplicate columns makes sense! Sometimes it’s the simple answer :smiley: Thank you!

One caveat with that is that topic columns are allowed to have “this/that/other” alternatives, but the request column isn’t. If you want to support that sort of thing then you either need extra rows for the alternatives or you need to write the request column as a regular expression instead, and change the matching accordingly. (Which is more powerful but a bit slower and harder to read.)

Oh, that’s good to know - I don’t think I put in anything with slashes but I did use “or”. Is that barred as well?

Yes, it is. You’ll have to put those on separate rows instead, or switch to using regular expressions.

Got it. Thanks! I’ll mess around with it a bit and see if it seems better to do this (probably with text substitutions so I don’t have to paste the response block in ten times) or if I should let it lie and just make the player type “talk about X”.

For reference, here’s an example that compiles (if you add some rooms and someone to talk to) and uses regular expressions:

Include Questions by Michael Callaghan.

Table of Conversation
topic	request	response
"bread" or "loaf"	"bread|loaf"	"'Smells nice, doesn't it?'"

Talking subjectlessly is an action applying to one thing.
Understand "talk to [someone]" as talking subjectlessly.

Instead of asking a person about a topic listed in the Table of Conversation:
	say "[response entry][paragraph break]".
	
Instead of talking subjectlessly:
	now current question is "What do you want to talk to [the noun] about?";
	now punctuation removal is true;
	ask an open question, in text mode.
	
A text question rule:
	repeat through the Table of Conversation:
		if current answer matches the regular expression request entry:
			say "[response entry][paragraph break]";
			exit.

(It gets a little trickier when you want to have multiple people with different responses – probably the cleanest way to handle that is to give each person a conversation table property and use that rather than directly referring to the Table of Conversation.)