I ran into a perceived gap in conversation capabilities. The situation is this, I have a pretty similar topic response that would like to be mildly tailored to the object under discussion, which means I need to know which object actually matched the Topic out of a list. ie
++ AskTellTopic [pokemon, neopet, bakugan, digimon]
"\"I don\'t know what <<[which one matched here???]>> is.\" "
;
My first attempt was
++ AskTellTopic [pokemon, neopet, bakugan, digimon]
"\"I don\'t know what <<gAction.getTopic().getBestMatch().aName>> is.\" "
;
This seemed to work, but had a pretty fatal flaw. If any of the vocabulary was shared by items NOT in the list, say >ask ash about electric mouse
, the topic would be activated correctly, indicating an initial match, but the reported object could be different! Ie, I might activate the topic via Pikachu, but get the message "I don't know what a computer mouse is."
For some reason I could not figure out, it does not necessarily resolve to the same/original object! I assume this has to do with the āarbitraryā matching described in the documentation.
Ultimately, the way I chose to address this was to modify the base TopicMatchTopic class:
modify TopicMatchTopic
actualMatch_ = nil // new property - JJMcC
findMatchObj(obj, rt) {
/* check the "in scope" list */
if (rt.inScopeList.indexOf(obj) != nil) {
actualMatch_ = obj; // added property setting - JJMcC
return true;
}
/* check the "likely" list */
if (rt.likelyList.indexOf(obj) != nil) {
actualMatch_ = obj; // added property setting - JJMcC
return true;
}
actualMatch_ = nil;
return nil;
}
;
Then, I can safely reference things as follows:
++ AskTellTopic [pokemon, neopet, bakugan, digimon]
"\"I don\'t know what <<actualMatch_.aName>> is.\" "
;
I offer this, as this was a DEEP hole of reverse engineering maybe someone else can avoid. (And in case there was an easier solution that eluded me).
One might need to make an analagous change to ThingMatchTopicās matchTopic
if similar customization is needed for Give or Show.