Is there a straightforward way to handle noun-based keyword actions in TADS 3?
Say I want the player to be able to type the name of an object and automatically take that object. I tried something like this:
DefineTAction(Keyword);
VerbRule(Keyword)
[badness 1000]
singleDobj
: KeywordAction
verbPhrase = 'keyword/keywording (what)'
;
That did what I wanted it to: the dobjFor(Keyword) functions were called, which I could remap to dobjFor(Take). However, this completely lobotomized the disambiguation process. Output was something like this:
My current approach involves generating a list of vocab words for all keyword objects in the game, then replacing them with ‘keyword ’ if they are entered as a single command. I also make a half-hearted effort to prevent disambiguation from blowing up. My concern is that this lacks any finesse whatsoever.
[spoiler][code]
DefineTAction(Keyword);
VerbRule(Keyword)
‘keyword’ singleDobj
: KeywordAction
verbPhrase = ‘keyword/keywording (what)’
;
modify Actor
ambigAction = nil
;
modify playerMessages
askMissingObject(actor, action, which)
{
inherited(actor, action, which);
actor.ambigAction = action;
}
;
StringPreParser
doParsing(str,which)
{
str = str.toLower();
if (!gActor.ambigAction)
{
foreach (local keyword in allKeywords.lst())
{
if (rexSearch('^' + keyword + '$', str))
str = str.findReplace(keyword, 'keyword ' + keyword, ReplaceOnce);
}
}
gActor.ambigAction = nil;
return str;
}
;[/code][/spoiler]