TADS 3: Coding a mobile phone

I am trying to write something that implements a mobile phone in a game, so that the player can phone and then talk to another actor in a remote location. So far I have created a SenseConnector between two phones which lets the player talk to the actor in a remote location. I plan to move one end of the sense connector in and out of the NPCs mobile phone using the Phone verb which I defined.

My problem is I can’t get the Phone verb to work for the other NPC when they are in a remote location. I have tried adding my NPC in to getExtraScopeItems but that doesn’t do what I thought it would

Am I doing something obviously wrong or is there something else I can try? Thanks.

The code below gets me…

Start Room
This is the starting room.

Phone bob
You cannot see him.

x bob
You cannot see him.

talk to bob
“Hello, there!” you say.
“Hi!” Bob replies, turning to you with a smile.

Test code…

startRoom: Room ‘Start Room’
"This is the starting room. "
east = otherPlace
;

  • me: Actor
    ;

++ myPhone: Thing ‘my phone’ ‘my phone’
"It is your phone. "
getExtraScopeItems(actor)
{
return bob;
}
;

otherPlace: Room ‘Other Place’
"This is somewhere else. "
west = startRoom
;

bob: Person ‘tall thin man/bob*men’ ‘Bob’
"He’s a tall, thin man. "
location = otherPlace
isHim = true
isProperName = true
;

  • bobPhone: Thing ‘Bob's phone’ ‘Bob's phone’
    "It is Bob's phone. "
    ;

  • bobTalking: InConversationState
    attentionSpan = 5
    specialDesc = "Bob is standing by the shop window, waiting for you to
    speak. "
    stateDesc = "He’s waiting for you to speak. "
    ;

++ AskTopic @bob
“Bob talks about himself”
;

++ bobLooking: ConversationReadyState
isInitState = true
commonDesc = " standing in the street, peering into a shop window. "
specialDesc = “Bob is <>”
stateDesc = “He’s <>”
;

+++ HelloTopic, StopEventList
[
'Hello, there! you say.\b
Hi! Bob replies, turning to you with a smile. ',
'Hello, again, you greet him.\b
Yes? he replies, turning back to you. ’
]
;

communicationLink: SenseConnector, Intangible ‘comms communication link’ ‘comms link’
locationList = [myPhone, bobPhone]
transSensingThru(sense)
{
return sense == sound ? distant : opaque;
}
;

DefineTAction(Phone);

VerbRule(Phone)
( ‘phone’ | ‘call’ | ‘telephone’ ) singleDobj
: PhoneAction
verbPhrase = ‘phone/phoning (what)’
;

modify Thing
dobjFor(Phone)
{
preCond = [touchObj]
verify()
{
if(gActor == self) illogical('{You/he} can't phone {yourself}! ‘);
else if(!ofKind(Person)) illogical(’{You/he} can't phone {the dobj/him}. ');
}
check()
{
"{The dobj/he} probably wouldn't answer. ";
exit;

}

}
;

modify Person
defaultPhoneMsg = "{You/he} phone{s} <>. "
dobjFor(Phone)
{
check() {}
action()
{
defaultPhoneMsg;
// Move one end of the Sense Connector here to allow conversation…
}
}
;

I haven’t tested this, but I notice you have preCond=[touchObj] on your new verb. That means that the action can only occur when Bob is touchable, and he won’t be touchable through the senseConnector.

For future reference, you can use the Code and Quote tags in the forum’s input interface to make your messages easier to read.

Are you using the adv3 or adv3lite library?

The adv3lite library has a commLink object for this very purpose:

commLink.connectTo(Actor);

…opens up communication channel between the PC and the Actor, so they can talk without being in the same location, a.k.a. via mobile phone.

Jerry

If you’re using the standard adv3 library and not adv3Lite, you might want to check out the article on scope in the TADS 3 Technical Manual, which has a section on how to implement a telephone that allows the PC to talk to an actor in a remote location. The subsection on Remote Sensory Scope should give you what you need.

Thank you. It was as simple as removing the preCond.