ConsultTopic expression mismatch

HELP!

I have two topics (out of 181) labelled ‘cabinet’ and ‘cabinet secretary’ but the expression is only matched on the first word no matter which order the topics are placed. Is this a limitation of consultTopic ie consult x about y where y in this case is a single word?

ConsultTopic is a TopicMatchTopic, so a phrase can contain an arbitrary amount of words (or even a regular expression that matches patterns.) It would probably help if you posted the affected ConsultTopic objects.

Here, this works just fine:

[code]+ Consultable {
‘book’ ‘book’
"It’s a book. "
}

++ ConsultTopic {
topicResponse = "Matched. ";
matchPattern = ‘foo bar’;
}[/code]

consult book about foo
You can’t seem to find that in the book.

consult book about foo bar
Matched.

explain please why the first two match correctly but the last two only match on ‘cabinet’

[code]+++ ConsultTopic
{
topicResponse = "Cabinet Secretary - The senior civil servant of the UK. The permanent non-political head of the Cabinet Office. ";
matchPattern = ‘cabinet secretary’;
}

+++ ConsultTopic
{
topicResponse = "Cabinet - The Prime Minister and her senior ministers of the crown, i.e. the committee that runs the UK. ";
matchPattern = ‘cabinet’;
}

+++ ConsultTopic ‘cabinet secretary’
"Cabinet Secretary - The senior civil servant of the UK. The permanent non-political head of the Cabinet Office. "
;

+++ ConsultTopic ‘cabinet’
"Cabinet - The Prime Minister and her senior ministers of the crown, i.e. the committee that runs the UK. "
;
[/code]

Looks like an issue with the templates. I’m not sure what’s happening. It’s probably worth reporting at bugdb.tads.org.

You need to adjust the matchScore of your topics. Since “consult book about cabinet” can match both, it will always match the topic it finds first (for some arbitrary, VM dependent value of first.)

It’s possible that the default order is based on source code order, and using templates arranges things differently at compile time - that would be the issue that NC mentioned. But I wouldn’t call that a bug; it’s just undefined behavior to be avoided.

I’ve tested the following code and it seems to work.

+ Consultable 'grimoire' 'GRIMOIRE'
	"It's bound in what appears to be human skin. "
;

++ ConsultTopic +80 'death'
	"You peruse the pages of the ancient grimoire. If the hour of your death was prophesied, it is not recorded here. "
;

++ ConsultTopic +100 'death spell'
	"After hours of sanity-blasting study, you master the awful syllables of the DEATH spell! "
;

That doesn’t explain why “death spell” won’t be matched at all. There’s no other topic that could match it, so a score should not be needed.

I can’t recreate the case where the full phrase (‘cabinet secretary’ or ‘death spell’) is not matched at all, only the case where it matches the less specific topic.

‘secretary’ or ‘spell’ alone won’t match; you’d need to modify the match pattern to allow that.

+++ ConsultTopic 'secretary|cabinet secretary'
   "Cabinet Secretary - The senior civil servant of the UK.  The permanent non-political head of the Cabinet Office. "
;

RE: your consult topic example, you’re correct that it matches ‘foo bar’ and not ‘foo’. However, it will also match anything that includes ‘foo bar’:

So if you had a ‘foo bar baz’ topic, the same issue would appear, with the same solution - specifying a match score to define the correct behavior.

many thanks bcressey for fixing the problem!

[code]+ cencomComputer : Heavy, Consultable ‘cencom computer’ ‘cencom’
desc()
{
cls();
”;
}
;

++ ConsultTopic +100 ‘cabinet secretary’
"Cabinet Secretary - The senior civil servant of the UK. The permanent non-political head of the Cabinet Office. "
;

++ ConsultTopic +50 ‘cabinet’
"Cabinet - The Prime Minister and her senior ministers of the crown, i.e. the committee that runs the UK. "
;

++ ConsultTopic +75 ‘cabinet office’
"Cabinet Office - Government department responsible for working directly for the Cabinet. "
;[/code]