Is there a straighforward design pattern/recipe for a window (or other SenseConnector
) that only “transmits” when directly interacted with?
The basic behavior I want is to have stuff in another room visible when looking through a window, but only when looking through a window. The examples in the T3 documentation illustrate how to set up a window that doesn’t cause remote objects to be listed until it is looked through (via swapping the connectorMaterial
in dobjFor(LookThrough)
, but that results in remote objects always showing up in the room contents after the window has been looked through once. Swapping the material back would prevent this behavior, but would prevent the remote objects from being directly examined, which is also undesirable.
Here’s sample code illustrating what I have, which is not quite what I want:
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
startRoom: Room 'Void'
"This is a featureless void with a window. "
;
windowRoom: Room 'Room With A View'
"This is the room with a window. "
;
+ pebble: Thing 'small round pebble' 'pebble'
"It's a small, round pebble. "
;
window: SenseConnector, Fixture 'window' 'window'
connectorMaterial = adventium
locationList = [ startRoom, windowRoom ]
dobjFor(LookThrough) {
verify() {}
check() {}
action() {
local otherLocation;
connectorMaterial = glass;
if(gActor.isIn(startRoom)) {
otherLocation = windowRoom;
"You look through the window at the other
room. ";
} else {
otherLocation = startRoom;
"You look through the window at the start
room. ";
}
gActor.location.listRemoteContents(otherLocation);
}
}
;
modify Thing
listLocation_ = nil
listRemoteContents(otherLocation) {
listLocation_ = otherLocation;
try {
lookAround(gActor, LookListSpecials | LookListPortables);
}
finally {
listLocation_ = nil;
}
}
adjustLookAroundTable(tab, pov, actor) {
inherited(tab, pov, actor);
if(listLocation_ != nil) {
local lst = tab.keysToList();
lst.forEach(function(cur) {
if(!cur.isIn(listLocation_))
tab.removeElement(cur);
});
}
}
;
me: Person
location = startRoom
;
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 yields:
Void
This is a featureless void with a window.
>x pebble
You see no pebble here.
>l through window
You look through the window at the other room.
In the room with a view, you see a pebble.
>x pebble
It's a small, round pebble.
>l
Void
This is a featureless void with a window.
In the room with a view, you see a pebble.
And this is mostly what I want, except I would like for the pebble to not show up in the description of startRoom
even after the window has been looked through.
This is certainly approachable as kludge; you can always just implement a bunch of fake scenery objects that shadow the appearance of, like:
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
startRoom: Room 'Void'
"This is a featureless void with a window. "
;
+ window: Fixture 'window' 'window'
"This is a window that's not a SenseConnector. "
dobjFor(LookThrough) {
verify() {}
check() {}
action() {
"You look through the window at the other
room.
<.reveal window>
<<if (pebble.location == windowRoom)>>
Sitting on the ground in the other room
you notice a pebble.
<<end>> ";
}
}
;
+ fakePebble: Fixture 'small round pebble' 'pebble'
desc() {
if(gRevealed('window')) {
pebble.desc();
} else {
"You don't see any pebble here. ";
}
}
;
windowRoom: Room 'Room With A View'
"This is the room with a window. "
;
+ pebble: Thing 'small round pebble' 'pebble'
"It's a small, round pebble. "
;
me: Person
location = startRoom
;
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
;
Which does what I want:
Void
This is a featureless void with a window.
>x pebble
You don't see any pebble here.
>l through window
You look through the window at the other room. Sitting on the ground in the
other room you notice a pebble.
>x pebble
It's a small, round pebble.
>l
Void
This is a featureless void with a window.
This actually works out to be more straightforward for this simple example, but rapidly gets out of hand as the number of objects that have to be “duplicated” grows.