Removing a Default Message?

Specifically, the “so-and-so comes with you” from an accompanying NPC. I’ve been searching through the code, trying to figure out what property or method I need to tweak, but it’s like looking for a flea in a bowl of rice. :unamused:

Basically, I want to replace “X comes with you” with my own message. I tried adapting the beforetravel method:

+hansFollow: AccompanyingState
    isInitState = true
    beforeTravel(traveler, connector)
    {
        "Hans <<rand('comes along with', 'follows', 'stays by')>> you, 
        <<rand(nil, 'tightly')>>
        <<rand('clinging to', 'holding on to' )>> your apron. ";
        inherited(traveler, connector);
    }
;

and all it really did was add my lines to the default message.

/sigh. Can anyone help me out, here?

Untested, but looking at AccompanyingState in the Library Reference Manual, its superclass tree includes TravelMessageHandler, from which it inherits a variety of methods, including sayArriving and sayDeparting. Most likely you want to override some of those.

–JA

Trying to figure things out from the library code isn’t always the best idea. In this case I’d suggest consulting the TADS 3 Technical Manual, specifically the section on Accompanying Travel in the article on Creating Dynamic Characters, which I think covers what you want to do here. The example there includes the following sample code:

 blurgEscortState: AccompanyingState, HermitActorState
    specialDesc = "The Blurg guard is keeping his hyperlaser
      trained on you. "
    stateDesc = "He has his hyperlaser pointed straight at you. "

    accompanyTravel(leadActor, conn) { return leadActor == gPlayerChar; }
    getAccompanyingTravelState(leadActor, conn)
      { return new BlurgEscortTravelState(location, leadActor, self); }
    
    noReponse = "Silence, feeble human! "
  ;

class BlurgEscortTravelState: AccompanyingInTravelState
     sayDeparting(conn) { "The Blurg guard prods you onward. "; }
     specialDesc = "<q>Keep moving, human scum!</q> the 
       Blurg guard growls. "
   ;

But you’ll need to consult the article for an explanation of that code if it’s not clear how to adapt it for your own use. The key step is to define a custom AccompanyingInTravelState on which you can define your own accompanying messages, and then to link it to the NPC’s AccompanyingState as in the above sample code.

There’s a further example, with a brief explanation, in the section on AccompanyingInTravelState in the TADS 3 Tour Guide. That example may be of interest in illustrating one way to have a randomly varying accompanying message.

– Eric

Thanks, Eric; it works now. :smiley: (And Jim, thanks to you too for trying). :slight_smile:

I’m a bit mystified by the setup, though; I mean, it switches from AccompanyingState to an AccompanyingInTravelState and then back again for one turn? Why is this tag-teaming necessary? I’d thought that the AccompanyingState was the one-stop-shop for all my tag-along NPC needs. o_O