Formalising aural and visual adjacency between rooms.

Just a note: it’s easier to look at your code if you inline it with code tags, rather than attaching it as a file. If it’s really long you can add spoiler tags outside the code tags.

To be frank, it’s really annoying when people do that. The code viewport already has a certain maximum length after which scroll bars appear, so the spoiler tags just add an extra click. Or is it not so in the default theme? (I’m using the whatever the alternative theme is called.)

I’ve never seen scroll bars in the code window in the main theme.

That’s a shame, it’s a really useful feature. Carry on then :slight_smile:

I’ll keep that in mind in the future.

As an aside, a third approach to the whole “examining via” thing occurred to me. I could stick a check rule at the top of the relevant rulebook (check examining, check listening, etc.) that determines what the player’s sensory connection to the noun is, and shoves that object in a global variable - call it that “vantage”, say. Then one could write rules like “instead of examining the fountain while the vantage is the second-floor window”, or “rule for printing the name of the intruder while the vantage is a security camera”. That would cover both the instead/after and while cases with a relatively straightforward - albeit somewhat cumbersome - syntax.

The only problem is that you wouldn’t be able to write vantage-based before rules, since before precedes check.

Hmm. Alternatively, a decide rule could be used to determine the vantage on the fly, but then I’m right back at potentially provoking a recursive scope check.

There is Jeff Nyman’s “Descriptions and Locale” at http://zurlocker.typepad.com/files/nyman—inform7-locale.pdf

Wow - that’s very in-depth. Thanks!

What about a set of “First before” rules? Then the user could employ both “before” and “check” rules.

I actually didn’t know about “first before” rules.

Okay - here’s a revised version trying it that way:

[spoiler][code]“Sensory Connections” by David J Prokopetz

Include Scope Caching by Mike Ciul.
Include Deluxe Doors by Emily Short.

Section 1 - Basic Sensory Properties

Visual adjacency relates various rooms to each other. The verb to be visually adjacent to implies the visual adjacency relation.
Aural adjacency relates various rooms to each other. The verb to be aurally adjacent to implies the aural adjacency relation.

Visual occlusion relates various things to each other. The verb to be visually occluded from implies the visual occlusion relation.
Aural occlusion relates various things to each other. The verb to be aurally occluded from implies the aural occlusion relation.

Audibility relates a thing (called the listener) to a thing (called the subject) when the listener can hear the subject. The verb to be able to hear (he is heard) implies the audibility relation.

A thing has a text called a sound.
A thing has a text called an aural description.
A thing has a text called an ambient aural description.
A thing can be silent, quiet or noisy (this is the noisiness property). A thing is usually quiet.

A room has a text called a sound.
A room has a text called an aural description.
A room can be silent, quiet, or noisy (this is the noisiness property). A room is usually quiet.

A container can be soundproof. A container is usually not soundproof.

A thing can be audible only.

The vantage is an object that varies.

Section 2 - Sensory Adjacency

The sensory dummy is a thing.

After deciding the scope of a person (called the viewer):
if the viewer is not enclosed by a closed opaque container:
repeat with the locale running through rooms which are visually adjacent to the location of the viewer:
if the locale is not dark:
now the sensory dummy is in the locale;
repeat with the item running through things enclosed by the locale:
if the item is not the sensory dummy and the sensory dummy can see the item:
place the item in scope, but not its contents;
mark the visibility of the item;
remove the sensory dummy from play;

Section 3 - Doors As Viewports

A door can be visually transparent, visually opaque when closed, or always visually opaque. A door is usually visually opaque when closed.
A door can be aurally transparent, aurally opaque when closed, or always aurally opaque. A door is usually aurally opaque when closed.

Definition: a door is visually open rather than visually closed if it can be seen through.
To decide whether (the portal - a door) can be seen through:
if the portal is visually transparent or (the portal is open and the portal is not always visually opaque):
decide yes;
otherwise:
decide no;

Definition: a door is aurally open rather than aurally closed if it can be heard through:
To decide whether (the portal - a door) can be heard through:
if the portal is aurally transparent or (the portal is open and the portal is not always aurally opaque):
decide yes;
otherwise:
decide no;

To decide what object is a viewport between (A - a room) and (B - a room):
repeat with the portal running through visually open doors enclosed by A:
if the reverse side of the portal is enclosed by B:
decide on the portal;
decide on nothing;

To decide what object is an aural viewport between (A - a room) and (B - a room):
repeat with the portal running through aurally open doors enclosed by A:
if the reverse side of the portal is enclosed by B:
decide on the portal;
decide on nothing;

To decide what object is a sight-only viewport between (A - a room) and (B - a room):
repeat with the portal running through visually open aurally closed doors enclosed by A:
if the reverse side of the portal is enclosed by B:
decide on the portal;
decide on nothing;

After deciding the scope of a person (called the viewer):
repeat with the portal running through doors enclosed by the location of the viewer:
if the portal is visually open and the portal is marked visible and the reverse side of the portal is not nothing:
let the next room be the location of reverse side of the portal;
if the next room is not dark:
repeat with the item running through things enclosed by the next room:
if the item is not the reverse side of the portal and the reverse side of the portal can see the item and the item is not visually occluded from the portal and the item is not visually occluded from the reverse side of the portal:
place the item in scope, but not its contents;
mark the visibility of the item;

Section 4 - Transmitters and Receivers

A thing can be sight-transmitting. A thing is usually not sight-transmitting.
A thing can be sound-transmitting. A thing is usually not sound-transmitting.

A thing can be sight-receiving. A thing is usually not sight-receiving.
A thing can be sound-receiving. A thing is usually not sound-receiving.

Sensor linkage relates one thing to another (called the counterpart). The verb to be sense-linked to implies the sensor linkage relation. The verb to be sense-linked with implies the sensor linkage relation.

To decide what object is a visual link between (the viewer - a thing) and (the subject - an object):
let the cameras be a list of things;
if the subject is a room:
repeat with the camera running through sight-transmitting things enclosed by the subject:
if the camera is not enclosed by a closed opaque container:
add the camera to the cameras;
otherwise:
repeat with the camera running through sight-transmitting things enclosed by the location of the subject:
if the camera can see the subject:
add the camera to the cameras;
repeat with the camera running through the cameras:
if the viewer can see the counterpart of the camera and the counterpart of the camera is sight-receiving:
decide on the the camera;
decide on nothing;

To decide what object is an aural link between (the listener - a thing) and (the subject - an object):
let the microphones be a list of things;
if the subject is a room:
repeat with the microphone running through sound-transmitting things enclosed by the subject:
if the microphone is not enclosed by a closed soundproof container:
add the microphone to the microphones;
otherwise:
repeat with the microphone running through sound-transmitting things enclosed by the location of the subject:
if the microphone can hear the subject:
add the microphone to the microphones;
repeat with the microphone running through the microphones:
if the listener can hear the counterpart of the microphone and the counterpart of the microphone is sound-receiving:
decide on the microphone;
decide on nothing;

To decide what object is the visual-only link between (the viewer - a thing) and (the subject - an object):
let the cameras be a list of things;
if the subject is a room:
repeat with the camera running through sight-transmitting things enclosed by the subject:
if the camera is not enclosed by a closed opaque container:
add the camera to the cameras;
otherwise:
repeat with the camera running through sight-transmitting things enclosed by the location of the subject:
if the camera can see the subject:
add the camera to the cameras;
repeat with the camera running through the cameras:
if the viewer can see the counterpart of the camera and the counterpart of the camera is sight-receiving and (the camera is not sound-transmitting or the counterpart of the camera is not sound-receiving):
decide on the camera;
decide on nothing;

After deciding the scope of a person (called the viewer):
repeat with the screen running through sight-receiving things enclosed by the location of the viewer:
if the screen is marked visible and the counterpart of the screen is not nothing and the counterpart of the screen is sight-transmitting:
let the camera be the counterpart of the screen;
if the location of the camera is not dark:
repeat with the item running through things enclosed by the location of the camera:
if the item is not the camera and the camera can see the item and the item is not visually occluded from the camera and the item is not visually occluded from the screen:
place the item in scope, but not its contents;
mark the visibility of the item;

Section 5 - Remotely Examining

First before examining (this is the determine the vantage before examining rule):
if noun is not a direction and (the location of the noun is not the location of the player or the noun is enclosed by a closed opaque container which does not enclose the player):
let the camera be a visual link between the player and the noun;
if the camera is not nothing:
now the vantage is the camera;
otherwise:
let the viewport be a viewport between the location and the location of the noun;
if the viewport is not nothing:
now the vantage is the viewport;
otherwise if the location of the player is visually adjacent to the location of the noun:
now the vantage is the location of the player;
otherwise:
now the vantage is nothing;
continue the action;

Before examining (this is the announce the vantage while examining rule):
if the vantage is sight-transmitting:
say “(via [the counterpart of the vantage])”;
otherwise if the vantage is a door:
say “(beyond [the reverse side of the vantage])”;
otherwise if the vantage is a room:
let the heading be the best route from the vantage to the location of the noun, using even locked doors;
say “(to [the heading])”;

Section 6 - Remotely Viewing Rooms

Viewing is an action applying to one visible thing.

Check viewing:
if the noun is not a room:
stop the action;

Carry out viewing (this is the standard viewing rule):
if the vantage is sight-transmitting:
say “Via [the counterpart of the vantage], you can see [the noun].”;
otherwise if the vantage is a door:
say “Beyond [the vantage], you can see [the noun].”;
otherwise:
let the heading be the best route from the vantage to the noun;
say “To [the heading], you see [the noun].”;
[print a description or list visible contents here?]

Section 7 - Examining Directions, Viewports, and Sensory Connectors

The connection-aware examine directions rule is listed instead of the examine directions rule in the carry out examining rulebook.
Carry out examining (this is the connection-aware examine directions rule):
if the noun is a direction:
let the next room be the room noun of the location;
if the next room is not nothing:
let the viewport be a viewport between the location and the next room;
if the viewport is not nothing:
now the vantage is the viewport;
otherwise:
now the vantage is the location;
try viewing the next room;
now examine text printed is true;
otherwise:
abide by the examine directions rule;
otherwise:
abide by the examine directions rule;

The examine doors rule is listed before the examine undescribed things rule in the carry out examining rulebook.
Carry out examining (this is the examine doors rule):
if the noun is a door and the noun is visually open and the reverse side of the noun is not nothing:
now the vantage is the noun;
try viewing the location of the reverse side of the noun;
now examine text printed is true;

The examine visual connectors rule is listed before the examine undescribed things rule in the carry out examining rulebook.
Carry out examining (this is the examine visual connectors rule):
if the noun is sight-receiving and the counterpart of the noun is sight-transmitting:
now the vantage is the counterpart of the noun;
try viewing the location of the counterpart of the noun;
now examine text printed is true;

Section 8 - Audibility

To decide whether (the listener - a thing) can hear (the subject - a thing):
if the subject is silent:
decide no;
if the location of the subject is nothing:
decide no;
if the listener is the subject:
decide yes;
repeat with the microphone running through sound-transmitting things enclosed by the location of the subject:
if the microphone is not the listener and the microphone is not the subject: [prevent feedback loops]
if the microphone can hear the subject and the subject is not aurally occluded from the microphone and the counterpart of the microphone is not nothing and the counterpart of the microphone is sound-receiving and the subject is not aurally occluded from the counterpart of the microphone and the location of the listener is the location of the counterpart of the microphone and the listener can hear the counterpart of the microphone:
decide yes;
repeat with the portal running through aurally open doors in the location of the subject:
if the portal is not the listener and the portal is not the subject: [prevent feedback loops]
if the portal can hear the subject and the subject is not aurally occluded from the portal and the reverse side of the portal is not nothing and the subject is not aurally occluded from the reverse side of the portal and the location of the listener is the location of the reverse side of the portal and the listener can hear the reverse side of the portal:
decide yes;
if the location of the listener is the location of the subject:
if a closed soundproof container that encloses the listener does not enclose the subject:
decide no;
otherwise if a closed soundproof container that encloses the subject does not enclose the listener:
decide no;
otherwise:
decide yes;
otherwise if the location of the listener is aurally adjacent to the location of the subject:
if a closed soundproof container encloses the listener or a closed soundproof container encloses the subject:
decide no;
otherwise:
decide yes;
otherwise:
decide no;

Definition: Something is audible rather than inaudible if the player can hear it.

[Sometimes we need to know why a given listener can’t hear something.]
To decide what object is the nearest aural barrier between (the listener - a thing) and (the subject - a thing):
let the first candidate be a random soundproof container that encloses the listener which does not enclose the subject;
if the first candidate is not nothing, decide on the first candidate;
let the second candidate be a sight-only viewport between the location of the listener and the location of the subject;
if the second candidate is not nothing, decide on the second candidate;
let the third candidate be a random soundproof container that encloses the subject;
if the third candidate is not nothing, decide on the third candidate;
decide on nothing;

[This allows the player to listen to things they can only hear.]

Before listening (this is the reset audibility flags before listening rule):
now everything is not audible only;
cache the scope for the player;

After deciding the scope of the player while listening:
repeat with the noisemaker running through noisy audible things:
if the noisemaker is not marked visible:
now the noisemaker is audible only;
place the noisemaker in scope, but not its contents;

Section 10 - Listening

Check listening to (this is the must be able to hear in order to listen rule):
if the noun is a room:
continue the action;
otherwise:
if the actor can hear the noun:
continue the action;
otherwise:
let the display be the visual-only link between the actor and the noun;
if the display is not nothing and the player cannot see the counterpart of the display:
say “(via [the display])[line break]You can’t hear anything via [the display].”;
rule fails;
otherwise:
let the barrier be the nearest aural barrier between the actor and the noun;
if the barrier is not nothing:
say “(through [the barrier])[line break]You can’t hear anything through [the barrier].”;
otherwise:
say “You can’t hear [the noun] from here.”;
rule fails;

The listening to action has a truth state called listen to text printed.

Carry out listening to (this is the standard listening to rule):
if the noun provides the property aural description and the aural description of the noun is not “”:
say “[the aural description of the noun][line break]”;
now listen to text printed is true.

Carry out listening to (this is the print local sounds when listening to rooms rule):
if the noun is a room:
repeat with the noisemaker running through audible things enclosed by the noun:
if the noisemaker provides the property ambient aural description and the ambient aural description of the noisemaker is not “”:
say “[the ambient aural description of the noisemaker][line break]”;
now the listen to text printed is true;
otherwise if the noisemaker provides the property sound and the sound of the noisemaker is not “”:
if the noisemaker is not audible only:
say “From [the noisemaker], you hear [the sound of the noisemaker].”;
otherwise:
if a visible closed opaque container (called the enclosure) encloses the noisemaker:
say “From [the enclosure], you hear [the sound of the noisemaker].”;
otherwise:
say “From somewhere close by, you hear [the sound of the noisemaker].”;
now the listen to text printed is true;

Carry out listening to (this is the print noisy sounds via aurally open doors when listening to rooms rule):
if the noun is a room:
let the noises be a list of texts;
repeat with the portal running through audible aurally open doors enclosed by the noun:
if the reverse side of the portal is not nothing:
let the noises be {};
repeat with the noisemaker running through noisy audible things enclosed by the location of the reverse side of the portal:
if the noisemaker provides the property sound and the sound of the noisemaker is not “”:
add the sound of the noisemaker to the noises;
if the noises is not empty:
say “Beyond [the portal], you hear [the noises].”;
now the listen to text printed is true;

Carry out listening to (this is the print noisy sounds in aurally adjacent rooms when listening to rooms rule):
if the noun is a room:
let the noises be a list of texts;
repeat with the next room running through rooms which are aurally adjacent to the noun:
let the noises be {};
repeat with the noisemaker running through noisy audible things enclosed by the next room:
if the noisemaker provides the property sound and the sound of the noisemaker is not “”:
add the sound of the noisemaker to the noises;
if the noises is not empty:
let the heading be the best route from the noun to the next room;
say “To [the heading], you hear [the noises].”;
now the listen to text printed is true;

Carry out listening to (this is the listen to aurally undescribed things rule):
if the listen to text printed is false:
issue library message listening to action number 1 for the noun.

Section 11 - Remotely Listening

First before listening (this is the determine the vantage before listening rule):
if noun is not a direction and (the location of the noun is not the location of the player or the noun is enclosed by a closed soundproof container which does not enclose the player):
let the microphone be an aural link between the player and the noun;
if the microphone is not nothing:
now the vantage is the microphone;
otherwise:
let the viewport be an aural viewport between the location and the location of the noun;
if the viewport is not nothing:
now the vantage is the viewport;
otherwise if the location of the player is aurally adjacent to the location of the noun:
now the vantage is the location of the player;
otherwise:
now the vantage is nothing;
continue the action;

Before listening to (this is the announce the vantage before listening to rule):
if the vantage is sound-transmitting:
say “(via [the counterpart of the vantage])”;
otherwise if the vantage is a door:
say “(beyond [the reverse side of the vantage])”;
otherwise if the vantage is a room:
let the heading be the best route from the vantage to the location of the noun, using even locked doors;
say “(to [the heading])”;

Section 14 - Speaking and Conversing

Check asking about (this is the must be able to converse when asking about rule):
if the the actor can address the noun and the noun can respond to the actor:
continue the action;
otherwise:
rule fails;

Check telling about (this is the must be able to converse when telling about rule):
if the actor can address the noun and the noun can respond to the actor:
continue the action;
otherwise:
rule fails;

Check showing to (this is the must be able to see and respond to show rule):
if the second noun can see the noun:
if the the second noun can respond to the actor:
continue the action;
otherwise:
rule fails;
otherwise:
say “It’s no good showing anything - [the second noun] can’t see you from here.”;
rule fails;

Before asking someone to try doing anything (this is the must be able to hear to accept requests rule):
if the player can address the person asked:
continue the action;
otherwise:
rule fails;

To decide whether (the querent - a thing) can address (the listener - a thing):
if the listener cannot hear the querent:
let the barrier be the nearest aural barrier between the querent and the listener;
if the barrier is not nothing:
say “[The listener] can’t hear [the querent] through [the barrier].”;
otherwise:
say “[The listener] can’t hear [the querent] from here.”;
decide no;
decide yes;

To decide whether (the respondent - a thing) can respond to (the listener - a thing):
if the listener cannot hear the respondent:
let the barrier be the nearest aural barrier between the listener and the respondent;
if the barrier is not nothing:
say “[The listener] can’t hear [the respondent]'s response through [the barrier].”;
otherwise:
say “[The listener] can’t hear [the respondent]'s response from here.”;
decide no;
decide yes;

Section 13 - Modified Reaching Rules For Listening, Speaking and Conversing

Listening to is hearing.

Answering is speaking.
Asking is speaking.

Asking about is conversing.
Telling about is conversing.

The block listening rule is not listed in any rulebook.
The block showing rule is not listed in any rulebook.

The sense-aware can’t reach inside closed containers rule is listed instead of the can’t reach inside closed containers rule in the reaching inside rules.
This is the sense-aware can’t reach inside closed containers rule:
if conversing:
if the person reaching can hear the noun and the noun can hear the person reaching:
allow access;
otherwise if hearing:
if the person reaching can hear the noun:
allow access;
otherwise if speaking:
if the person reaching can hear the player:
allow access;
otherwise:
abide by the can’t reach inside closed containers rule;

The sense-aware can’t reach inside rooms rule is listed instead of the can’t reach inside rooms rule in the reaching inside rules.
This is the sense-aware can’t reach inside rooms rule:
if conversing:
if the person reaching can hear the noun and the noun can hear the person reaching:
allow access;
otherwise if hearing:
if the person reaching can hear the noun:
allow access;
otherwise if speaking:
if the noun can hear the person reaching:
allow access;
otherwise:
abide by the can’t reach inside rooms rule;

Section 14 - Misc

[Make sure NPCs can see and hear via sensory connections as well.]
Before a person (called the viewer) trying doing something: cache scope for the viewer.

Section 99 - Sample Scenario

The Main Hallway is a room. “A hallway with well-worn red carpets. A creaky staircase leads up to the attic. The kitchen is to the west.”

The rusty key is a thing in the Main Hallway.

The lower creaky staircase is open, unopenable, always visually opaque scenery door. The lower creaky staircase is up from the Main Hallway. Through the lower creaky staircase is the Musty Attic. Understand “attic” and “stairs” as the lower creaky staircase. The printed name of the lower creaky staircase is “creaky staircase”.

The upper creaky staircase is an open, unopenable, always visually opaque scenery door. The upper creaky staircase is down from the Musty Attic. Through the upper creaky staircase is the Main Hallway. Understand “hallway” and “stairs” as the upper creaky staircase. The printed name of the upper creaky staircase is “creaky staircase”.

The upper creaky staircase is a half-door of the lower creaky staircase.

The Musty Attic is a room. “This attic has likely never been cleaned. A thick layer of dust and cobwebs coats everything you can see. A creaky staircase leads back down to the main hallway.”

The cardboard box is a closed openable container in the Musty Attic.

The antique music box is a noisy thing in the cardboard box. The sound of the antique music box is “soft, ethereal music”. The aural description of the antique music box is “Soft, haunting music [if audible only]fills the air[otherwise]issues from the box’s inner workings[end if].” Understand “ethereal” as the music box.

The upper trap door is a closed locked scenery door. The upper trap door is down from the Main Hallway. Through the upper trap door is the Hidden Laboratory. Understand “trapdoor” as the upper trap door. The printed name of the upper trap door is “trap door”. The rusty key unlocks the upper trap door.

The lower trap door is a closed locked scenery door. The lower trap door is up from the Hidden Laboratory. Through the lower trap door is the Main Hallway. Understand “trapdoor” as the lower trap door. The printed name of the lower trap door is “trap door”. The rusty key unlocks the lower trap door.

The Hidden Laboratory is a room. “Strange apparati line every wall. The glass-walled, soundproof testing chamber stands in the middle of the room, along with its current occupants: Subject 42 and his favourite weighted cube. An intercom panel adorns one wall, with a wire running to a matching speaker in the test chamber.”

The soundproof glass testing chamber is a closed unopenable enterable transparent soundproof scenery container in the Hidden Laboratory. Understand “glass-walled” as the soundproof glass testing chamber.

Subject 42 is a person. Subject 42 is in the soundproof glass testing chamber. Persuasion rule for asking Subject 42 to try doing something: persuasion succeeds.

The weighted cube is a portable enterable supporter in the soundproof glass testing chamber.

The intercom speaker is a scenery sound-receiving thing in the soundproof glass testing chamber.

The intercom panel is a scenery device in the Hidden Laboratory.
Carry out switching on the intercom panel: now the intercom panel is sound-transmitting.
Carry out switching off the intercom panel: now the intercom panel is not sound-transmitting.

The intercom speaker is sense-linked to the intercom panel.

The Kitchen is a room. “Sometimes food is prepared here. A tasteless clock shaped like a cartoon cat hangs on the wall, ticking loudly. The main hallway is to the east, and a screen door looking out on the yard is to the west.” The Kitchen is west of the Main Hallway. The Kitchen is visually adjacent to the Main Hallway. The Kitchen is aurally adjacent to the Main Hallway. Instead of viewing the Kitchen while the vantage is the Main Hallway, say “The west end of the hallway opens up into your small, cramped kitchen. You can see your pereptually empty refrigerator from here.”

The tasteless clock is a noisy scenery thing in the Kitchen. The sound of the tasteless clock is “loud ticking”.

The refrigerator is a fixed in place closed container in the Kitchen. Understand “fridge” as the refrigerator.

The interior screen door is a closed, openable, visually transparent, aurally transparent scenery door. The interior screen door is west of the Kitchen. Through the interior screen door is the Back Yard. The printed name of the interior screen door is “screen door”.

The exterior screen door is a closed, openable, visually transparent, aurally transparent scenery door. The exterior screen door is east of the Back Yard. Through the exterior screen door is the Kitchen. The printed name of the exterior screen door is “screen door”.

The exterior screen door is a half-door of the interior screen door.

The Back Yard is a room. “Your lawn is perpetually in need of mowing.”

Rule for printing the name of the Back Yard while viewing:
say “your perennially unmowed back yard”;

The red ball is a thing in the Back Yard.

The player is in the Main Hallway.

The portable camera is a sight-transmitting thing. The portable screen is a sight-receiving thing. The portable camera is sense-linked to the portable screen. The portable camera and the portable screen are carried by the player.

Instead of examining while the vantage is the portable camera, say “The resolution is too low to make out any details of [the noun].”[/code][/spoiler]
(Do people actually find it easier when code is inlined like this? Personally, I find it inconvenient, since the forum software converts tabs to spaces and they have to be converted back in order to actually run anything.)

There’s a hack; reply to the post to which you’re responding and copy the quoted code out of the message body box. Then tab stops will be preserved.

On the “First before:” question; does it make sense to write a new rulebook that runs before the Before rules? I haven’t done anything with new rulebooks.

“First before” is not a new rulebook. You can add “first” to any rule, and that will guarantee that it comes before any rule in the rulebook that doesn’t begin with “first” (“last” functions similarly). For example, the compiler will automatically order these four rules like so, whatever order they appear in your source:

  1. First before taking the butter
  2. First before taking something
  3. Before taking the butter
  4. Before taking something

Rather than making this a global variable, it might be best to make this an action variable, set using a Setting Action Variables for ing phrase. See WI 12.10.

That way you can set the Medium Examined Through, the Medium Listened Through, etc. variables. This would have the benefit of not overwriting that global variable in the middle of a complex calculation involving both visibility and audibility, for example.

That’s what I get for commenting when sleep-deprived. What I meant was, would it make sense to write a new rulebook instead of writing a bunch of “First before” rules?

Can action variables be fiddled with from “outside” the action in question? Currently, I have a “viewing” action defined for looking around a room you’re not in (i.e., as a remote counterpart of “look”), and I’ve run into cases where it’s necessary to explicitly keep track of what visual medium the player accessed in the event that there’s more than one - e.g., if there’s both a video screen connected to a camera in the target room, and an open door to the same room through which the player can look, I don’t want to see flavour text implying that the player peered through the door when they actually examined the video feed, or vice versa.

Well, at a minimum, you’d need to slot that new rulebook in by hacking the template layer (if you wanted it to be triggered by an action, anyway, as the OP seems to do).

But surely this (setting up circumstances for a particular action differently from the norm) is what Before rules are for? Marking the rules “first” is just a courtesy to users who might want to write their own Before rules that make use of the code you’ve triggered.

But I admit I haven’t been following this discussion, so maybe there’s a subtle point I’m missing!

No, action variables are not accessible outside the action. But I think the Setting Action Variables is the right place to define the viewport anyway, even if it’s actually a global variable. They run at the right time, and the viewport is effectively an action variable, although if it’s global you don’t get to use the nifty built-in syntax to add the “via” preposition.

One cool thing I discovered is that you can even use Setting Action Variables to set the same global for multiple actions. I’ve used this in my WIP, but it just occurred to me I should change all the Before rules in Speech Motivations to be Setting Action Variables rules too. Hmm… maybe, maybe not. The rules for finding an interlocutor can display an error and stop the action, which I wouldn’t want in a Setting Action Variables rule. If I can make it work, I might just do it anyway, setting the interlocutor to nothing if there’s a failure, and figuring out what went wrong in the Check rules.

Hmm. Do you mean setting a global variable during the “examine viewport” action before handing execution off to the “view room” action, then checking that variable in the Setting Action Variables rulebook for the view action and grabbing its value if one is present?

Sorry, I didn’t mean the viewport, I meant the vantage. Something like this:

[code]The vantage is an object that varies.

Setting action variables for examining or listening to:
Now the vantage is …

To decide whether examining via (the portal - an object):
if not examining, no;
decide on whether or not the vantage is the portal.[/code]

Hmm… that doesn’t work for writing “instead” rules, does it?

Anyway, opinion question: for sensory connections that involve two objects, does it make more sense for instead/while rules to pertain to the “near” side of the connection, or the “far” side of the connection? Suppose, for example, that I’m looking through a two-sided door (as defined by Emily Short’s Deluxe Doors extension): would it be more natural for the author to have to write any relevant rules in terms of the half of the door that faces the player, or the half of the door that faces the room or object being examined? Likewise, if you have a camera connected to a video screen, would it make more sense to require rules to be written from the standpoint of the camera (e.g., “instead of examining via the security camera”), or the screen (e.g., “instead of examining via the security monitor”)?

In a perfect world, it wouldn’t matter which end of the connection the author picked, of course, but I can’t come up with a way to enable that without making the syntax for writing such rules very cumbersome.

Unrelated question: is there any way to make directions valid nouns for the built-in “listen to” action? Everything I try seems to get blocked with a message “You must name something more substantial.”