For reasons that will become clear once you’ve played my Spring Thing entry, I’d like players to be able to ‘examine’ a room. Here’s what I’ve tried (with some rough edges):
Understand "examine [room]" as examining.
After deciding the scope of the player:
place the location in scope;
Check examining a room when the noun is not the location:
say text of the parser error internal rule response (E) instead;
Carry out examining a room when the noun is the location:
try looking;
stop the action;
Instead of doing something other than examining when the noun is a room (this is the can only examine a room rule):
say "That doesn't make sense." (A);
Rule for deciding whether all includes rooms: it does not.
Secret Lab is a room.
some lab equipment is in the secret lab.
test me with "trace 5/x lab"
If you run the test me, though, you’ll notice that the parser never even considers “lab equipment” as the direct object, only “secret lab”. Is there a way to cause the parser to consider both as a match?
The parser won’t disambiguate across multiple grammar lines. In this case, the two lines:
Understand "examine [room]" as examining.
Understand "examine [something]" as examining.
Really the easiest way to deal with this is to not mess around with scoping at all. Instead create a scenery object called “Secret Lab” in the secret lab, where examining that turns into a Look action.
Book - able to examine room
[Code by otistdog: https://intfiction.org/t/overly-elaborate-looking/50715/2]
After deciding the scope of the player while examining (this is the place the room in scope while looking rule): [limits applicability to when parsing examining action]
place the location in scope, but not its contents. [everything else should already be in scope if applicable]
Does the player mean doing anything to the location: [still prioritizes examination of things vs rooms]
it is unlikely.
Instead of examining a room:
try looking instead.
You can create a kind room-scenery and say Every room contains a room-scenery.
Then, with an Understand property as describing… you can match the room name.
The lab is a room. "This is the lab."
The kitchen is a room. "This is the kitchen."
It is north of the lab.
A room-scenery is a kind of scenery thing.
It has a text called the room-name.
The room-name is usually "[location of the item described]".
Understand the room-name property as describing a room-scenery.
Every room contains a room-scenery.
Instead of examining a room-scenery, try looking.
Test me with "x lab / n / x kitchen".
To prefer things that might share a word with the room name to the lab (like a “lab jacket” in The Lab) and to avoid its popping up in disambiguation / inference, I’d suggest adding:
does the player mean doing anything other than examining a room-scenery: it is very unlikely.
does the player mean examining something that is not room-scenery: it is likely.
And I’m not sure that takes care of every case, so just in case, it should probably have a reasonable printed name.
The printed name of a room-scenery is usually "[location of the item described]".
See here for chapter and verse on [something] and other grammar tokens.
Unhelpfully, [something] as a grammar token meaning object is a bit of an outlier in Inform: elsewhere (e.g. in the preamble of rules) it means a thing.