TADS3/adv3 automagically accepts the use of possessives to disambiguate between objects based on location. So >X ALICE'S PHONE
will work even if Alice’s phone is declared just as “phone”.
Unfortunately it doesn’t automagically use possessives to prompt for disambiguation, even if an explicit owner is declared. That’s easy enough to fix: just define disambigName
as theNameWithOwner
(and so on for the other similar disambiguation name properties, like theDisambigName
).
Handling switching between “the phone” and “her phone” to catch all the stock library messages that report using the {the dobj/him}
message parameter substitution and so on seems to be a little more tricky, unless I’m missing something. And I’m not convinced that I’m catching all the special cases (in fact, I’m pretty sure I’m not catching all of them).
So is there a simpler way to handle this?
Simple demo to illustrate: Alice and Bob and their phones. They’ll let you order them to drop and pick up their phones:
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
class PersonalItem: Thing
theName() {
if(owner != nil)
return(owner.itPossAdj + ' ' + name);
return(inherited);
}
disambigName() {
if(owner != nil)
return(theNameWithOwner);
return(inherited);
}
theDisambigName() {
if(owner != nil)
return(theNameWithOwner);
return(inherited);
}
aDisambigName() {
if(owner != nil)
return(aNameOwnerLoc(true));
return(inherited);
}
;
class Phone: PersonalItem 'phone' 'phone'
"It\'s <<theNameWithOwner>>. "
;
class PhonePerson: Person
obeyCommand(fromActor, action) {
if(action.ofKind(DropAction))
return(true);
if(action.ofKind(TakeAction))
return(true);
return(inherited(fromActor, action));
}
;
startRoom: Room 'Void'
"This is a featureless void. "
;
+me: Person;
+alice: PhonePerson 'Alice' 'Alice'
"She looks like the first person you'd turn to in a problem. "
isProperName = true
isHer = true
;
++alicePhone: Phone
owner = alice
;
+bob: PhonePerson 'Bob' 'Bob'
"He looks like a Robert, only shorter. "
isProperName = true
isHim = true
;
++bobPhone: Phone
owner = bob
;
versionInfo: GameID
name = 'sample'
byline = 'nobody'
authorEmail = 'nobody <foo@bar.com>'
desc = '[This space intentionally left blank]'
version = '1.0'
IFID = '12345'
;
gameMain: GameMainDef
initialPlayerChar = me
;
This produces more or less what I want insofar as my test cases so far go:
Void
This is a featureless void.
Alice and Bob are standing here.
>x alice's phone
It's Alice's phone.
>alice, drop phone
Alice puts down her phone.
>alice, take phone
Alice takes her phone.
>x phone
Which phone do you mean, Alice's phone, or Bob's phone?
>alice, drop phone
Alice puts down her phone.
>take phone
(Alice's phone)
Taken.
What I care about is just that the parser prefers to prompt for a possessive to disambiguate (without having to explicitly define a possessive on each object), and in general when the actors are fiddling with their “personal” items they’re “her phone” or “his phone” (instead of “Alice’s phone” or “Bob’s phone”, so you don’t get "Bob puts down Bob’s phone. " and so on), and when the player is fiddling around with them they’re (unless otherwise modified) “Alice’s phone” instead of “her phone”. If that all makes sense.