Executing Arbitrary Code From a Conversation

In my very simple conversation model, people have a keyword and phrase that they respond to for ask/tell. What I would like to add, to this two column table, is an arbitrary set of phrases that are executed when that keyword is referenced in the table.

Example:

Table of Morgan-Conversation
Topic	Reply	Action
"job"	"'Looks like somebody got murdered last night. Job is to figure out who did it and why. Pay on this one is pretty good.'"	--
"pay"	"'It pays fifty thousand. Can you get to the morgue tonight? We know someone down there who will let you take a look at the body.'"	--
"your mother"	"I'M OFFENDED! HOW DARE YOU INSULT ME!"	change emotion of Morgan to angry.

If the only kind of action I might perform would be to set the emotions of people, I could just have the column be the new emotional value and construct rules to set it. My problem is that I want to do a wide variety of things, so this is probably too limited.

Another choice might be to put stored actions into the column (I think this is possible?), but then I would have to define an action for each type of coded response, and there could be many.

What I (think I) really want is to put some phrase in the table that gets executed. Is that possible?

As far as I know, you can’t just put a phrase in a table like that. But you can put a reference to a rule, and then execute that rule when the corresponding topic is mentioned, like so:

[code]Table of Morgan-Conversation
Topic Reply Rule
“job” “‘Looks like somebody got murdered last night. Job is to figure out who did it and why. Pay on this one is pretty good.’” –
“pay” “‘It pays fifty thousand. Can you get to the morgue tonight? We know someone down there who will let you take a look at the body.’” –
“your mother” “I’M OFFENDED! HOW DARE YOU INSULT ME!” the insult Morgan rule

This is the insult Morgan rule:
change emotion of Morgan to angry.

After asking Morgan about a topic listed in the Table of Morgan-Conversation:
say the reply entry;
say paragraph break;
if there is a rule entry, consider the rule entry.[/code]
This lets you make your action as complex as you want. For instance, if you wanted Morgan to shoot the player because of the insult, you could do that:

This is the insult Morgan rule: change emotion of Morgan to angry; try Morgan shooting the player.

Bummer. If that is so, I wonder if I’m better off with eliminating the third column and just using ‘after’ rules?

e.g.

After asking Morgan about "your mother": change the emotion of Morgan to angry.

That’s what I ended up doing after a bunch of experimentation. In fact, eventually I ditched tables altogether and put the response in an after rule as well:

After asking Morgan about "your mother": say "'Don't you talk about my mother!' Morgan yells."; now Morgan is angry.
I’ve found that tables are generally a pain to use with anything involving long strings – it’s too hard to format. And using an after rule gives much more flexibility.

If you still want to use a table, another possibility is to use a “to say” rule which doesn’t actually print anything, eg. (untested code):

Table of Morgan-Conversation
Topic      Reply
"turtle"   "Who told you about the turtle?[Morgan -> suspicious]"

To say (p - a person) -> (e - an emotional state):
    change the emotion of p to e.

David