[i7][solved] Redirecting a response (Conversation Package)

Hi,

I just tried myself at redirecting the response for a specific topic string to another one using the Conversation Package by Eric Eve, and I failed:

[code]“conversationtest” by “bartax”

Include Conversation Package by Eric Eve.

The living room is a room. “You’re inside Lisa’s living room.”
Lisa is a person.
Lisa is in the living room.
Response for Lisa when asked for “abc”:
say “Lisa says ‘Test successful!’.”.
Response for Lisa when asked for “def”:
try asking Lisa for “abc” instead.[/code]The resulting error is:

If someone could give a clue on how to do this properly, I’d be very glad :slight_smile:

Please note with this code, I can actually type ask Lisa for abc just fine which is why I attempted this sort of redirect:[code]“conversationtest” by “bartax”

Include Conversation Package by Eric Eve.

The living room is a room. “You’re inside Lisa’s living room.”
Lisa is a person.
Lisa is in the living room.
Response for Lisa when asked for “abc”:
say “Lisa says ‘Test successful!’.”.[/code]

Do this:

Response for Lisa when asked for "def": try imploring Lisa for "abc" instead.

When you are using a “try…” command, you need an action name here. If you type the debug command “actions” and then type “ask lisa for abc,” you’ll see that the action involved is “imploring Lisa for ‘abc’”, so that’s what you want here.

Another resource that can help you figure out what to type is the Index; I think I saw you asking about this and no one answered. If you go to the Inform IDE, there are tabs down the right (at least on the Mac) that say “Source,” “Errors,” “Index,” “Skein,” etc. Click on “Index” and you’ll get a bunch of new tabs on the top. Click on the one that says “Actions” and you’ll get a list of the actions defined in the game; actions defined by the standard rules, actions defined by extensions, and actions defined by yourself. When you scroll down to “Actions defined by the extension Conversation Framework by Eric Eve” you get a list of those actions, and you can click on the magnifying glass next to it to get more information about it.

The documentation for Conversation Framework (which is included in Conversation Package) tells us that the command “ask X for Y” is redirected into two actions, requesting it for (when Y is a thing) and imploring it for (when Y is a topic, which is roughly any text string that doesn’t name a thing, though it can also encode functions like “abc/def” which would match “abc” or “def” which incidentally would be a simpler way to do what we’re doing in this code). To write a response for either of these we can say “response of Bob when asked for…” This is just a coding decision made in Eric Eve’s extensions; as he says it makes it easier to remember that you write “response of Bob when asked for” rules, though it’s a bit harder to remember the names of the actions when you have to invoke them directly. The idea, I think, is that you usually don’t have to write rules that refer directly to the action names, if you’re mostly writing conversation responses.

Hope this is helpful.

This was already very helpful! What you are suggesting works almost, however I just can’t get it to work in one very specific corner case (excuse the seemingly random code, I was trying to find a minimal reproduction case for something out of a much more complex game scenario and I had no idea what I was searching for):

This works:[code]“conversationtest” by “bartax”

Include Conversation Package by Eric Eve.

A def is a kind of thing.
An abc def is a kind of def.
The living room is a room. “You’re inside Lisa’s living room.”
Lisa is a person.
Lisa is in the living room.
Response for Lisa when asked for “def”:
try imploring Lisa for “abc def” instead.
Response for Lisa when asked for “abc def”:
if Lisa carries def:
say “Lisa says ‘Test successful!’.”;
otherwise:
say “Lisa shouts ‘Test successful!’.”.[/code]The successful output is:

And this doesn’t (the only difference is the new last line):[code]“conversationtest” by “bartax”

Include Conversation Package by Eric Eve.

A def is a kind of thing.
An abc def is a kind of def.
The living room is a room. “You’re inside Lisa’s living room.”
Lisa is a person.
Lisa is in the living room.
Response for Lisa when asked for “def”:
try imploring Lisa for “abc def” instead.
Response for Lisa when asked for “abc def”:
if Lisa carries def:
say “Lisa says ‘Test successful!’.”;
otherwise:
say “Lisa shouts ‘Test successful!’.”.

Lisa carries 2 abc def.[/code]The failing result is:

I have absolutely no idea what is going on here! :astonished:

Edit: Oh and thanks a lot for explaining the index, will go check it out now!

Ok the problem is that I would have needed to write: Response for Lisa when asked for abc def: … because now it’s obviously a real item. Once I do that, the problem goes away and things work. Yay :slight_smile:

Yeah, I’ve never used Conversation Package myself, but the “response when asked for” syntax seems a little unusual because it applies equally to topics and object names. The underlying actions are different, though. (If you wanted to redirect asking Lisa for the abc def to asking her for a different thing named the ghi, you’d have to say “Try requesting Lisa for the ghi instead.”)

As I said, this is a design decision in Eric Eve’s extensions. Looking through the code, the key part is this from Conversation Responses:

[code]To decide whether asked for (obj - an object):
if requesting someone for something, decide on whether or not the obj is the second noun;
decide no.

To decide whether asked for (atopic - a topic):
if imploring someone for something, decide on whether or not the topic understood matches atopic;
decide no.[/code]

The presence of both these phrases is why “asked for [an object]” and “asked for [a topic]” both make sense, even though they’re dealing with different underlying actions. So the command “ask” gets translated into requesting or imploring, depending on whether you’re dealing with an object or topic, and then if you’re checking “when asked for” it checks one of those phrases, depending on whether you’re looking at an object or a topic. In some ways the fact that “ask” is used in both cases is coincidental (but it makes the code much more readable).

Anyway, glad I could help!

Thanks for explaining this! You’re awesome matt w :slight_smile: