problem with new verb rule created in adv3lite

Using adv3Lite v0.8, I have created a new verb rule for “answer”. Superficially, it appears to work. When the player character enters “answer the phone” the response displayed is “Hello?” which is almost, but not quite, what I expected from how I wrote the new action.

There are problems.

I also specified a precondition that the object (the phone) must be held, which is being ignored.

Here’s the VerbRule and DefineTAction…

VerbRule(Answer) ('answer') singleDobj : VerbProduction action = Answer verbPhrase = 'answer/answering' missingQ = 'answer what' ; DefineTAction(Answer) execAction(Answer) { "\"Hello?\" {the subj harry} answered. "; } ;

…and here’s the precondition…

modify Thing dobjFor(Answer) { preCond = [objHeld] report() { "{the subj harry} answered the <<gDobj>>. "; } } ;

There is a cell phone (a Thing) on the table. Harry answers the phone without first picking it up. I expected the precondition would cause the system to say something like first picking the phone up though I’d settle for just Harry doesn’t have a phone on him. But it does neither and Harry’s inventory remains empty after the screen text has indicated that he answered the phone.

Also, the response() text specified in the modification to Thing is never displayed, only the execAction(Answer) text defined in DefineTAction(Answer).

Jerry

The main problem here is that you’ve overridden the execAction() method of the Answer action, which (normally) you should only ever do for an IAction, TopicAction or LiteralAction (but never for a TAction or TIAction). By doing that you’ve effectively obliterated the normal action processing for this verb, which is why it’s ignoring everything you’ve defined on Thing; you’ve overridden the code that would consult the precondition and the report() method with your own version of execAction(), so of course nothing works as it should.

What you need to do is remove your execAction() method from your definition of the Answer method.

Besides that, there are several places where your code isn’t quite right. It should read;

VerbRule(Answer)
    'answer' singleDobj
    : VerbProduction
    action = Answer
    verbPhrase = 'answer/answering (what)'
    missingQ = 'what do you want to answer'
;

DefineTAction(Answer)    
;

modify Thing
    dobjFor(Answer)
    {
        preCond = [objHeld]
        report() { "{I} answer{s/ed} {the dobj}. "; }
    }
;

It’s still a bit odd, though, since this could result in Harry answering any portable object, which I doubt is what you want. It would be more logical, and better practice, to do something like this:

modify Thing
    dobjFor(Answer)
    {
        preCond = [objHeld]
        verify() { illogical(cannotAnswerMsg); }
    }
    cannotAnswerMsg = '(I} {can\'t} answer {that dobj}. '
;

phone: Thing 'phone;;telephone'
  dobjFor(Answer)
  {
      verify() {}
      action()
      {
           "{I} answer{s/ed} {the dobj}. ";
       }
   }
;