I’ve figured it out … sort of. The difficulty, which may indeed be a library bug, has something to do with what happens when an object to be listed has a component. To see the difference, run the code below before and then after commenting out the photoListObject, which is a component of the cell phone object (which is in the purse). When photoListObject is present, the lister thinks the list is empty, even though it isn’t. At first I thought it might be because the makeupMirror is a component of the purse object itself, but commenting that out doesn’t prevent the problem – it’s when there’s an object in the container that has a component.
[code]Test ‘me’ [‘open purse’];
modify Thing
dobjFor(Open) {
action() {
makeOpen(true);
if(!gAction.isImplicit) {
unmention(contents);
listSubcontentsOf(self, myOpeningContentsLister);
}
}
}
myOpeningContentsLister = openingContentsLister
dobjFor(LookIn) {
action() {
if(contType == In) {
if(hiddenIn.length > 0)
moveHidden(&hiddenIn, self);
if(contents.length == 0)
display(&lookInMsg);
else
{
unmention(contents);
if(gOutStream.watchForOutput(
{: listSubcontentsOf(self, myLookInLister) }) == nil)
display(&lookInMsg);
}
}
else if(hiddenIn.length > 0)
findHidden(&hiddenIn, In);
else
display(&lookInMsg);
}
}
myLookInLister = lookInLister
;
purseOpeningContentsLister: openingContentsLister
showListPrefix(lst, pl, parent) {
gMessageParams(parent);
"In addition to the mirror mounted
beneath the flap, your purse contain{s/ed} ";
}
showListEmpty(parent) {
// if (purse.contents.length() == 1)
"Your purse is empty, except for the mirror mounted beneath the flap. ";
}
;
purse: OpenableContainer ‘purse; leather scuffed my; pocketbook handbag bag flap’ @me
"It’s not your favorite purse — the leather is a bit scuffed. You grabbed it
in a hurry on your way out the door, without loading it with the assortment of
things you usually carry — only the bare necessities. << if isOpen>>Attached
to the underside of the flap is a makeup mirror. "
theName = ‘your purse’
aName = ‘your purse’
bulkCapacity = 10
bulk = 15
openStatusReportable = nil
myOpeningContentsLister = purseOpeningContentsLister
myLookInLister = purseOpeningContentsLister
;
-
makeupMirror: Component ‘makeup mirror’
"The makeup mirror is mounted beneath the flap of the purse. It’s rectangular,
and large enough that you can see a good portion of your face in it, or check your hair. "
hideFromAll(action) {
return true;
}
lookInMsg = 'By holding the mirror at just the right angle, you can see
yourself. ’
cannotTakeMsg = 'You can’t remove the mirror; it’s part of the purse. ’
;
-
cellPhone: Thing ‘cell phone; smart’
"Your cell phone is a couple of years old, and its link to a carrier has become almost completely
unreliable, to the point where you don’t even think about using it as a phone anymore. It’s still
handy as a camera, however. You can take pictures with it, and then look at the
pictures. "
photoList = []
showPhotoList() { }
addToPhotos(x) { }
;
// Comment out the photoListObject to make the lister problem go away:
++ photoListObject: Component
‘photo display ;video graphic LCD; picture pictures photos photograph photographs snapshot snapshots’
desc {
local len = cellPhone.photoList.length();
if (len == 0) "You haven't taken any photos yet. ";
else {
"In your cell phone's video display, you can
see <<if (len == 1)>>a photo<<else>>photos<<end>> of ";
cellPhone.showPhotoList();
}
}
;[/code]