Examining rooms, or using mutually exclusive grammar tags for the same command

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.

3 Likes

Well then I want a macro that will automatically create scenery from rooms. :wink:

Seriously, though, thanks for saving me some frustration.

Here’s what I used in Daddy’s Birthday:

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.

Here’s a link to the original code: Overly elaborate looking - #2 by otistdog

1 Like

Oh for heaven’s sake, [something] includes all objects? Not just things? :man_facepalming:

Kind of off-topic, but what does this do:

I see it at the end of a lot of Inform 7 code chunks. Is this some kind of built in unit testing? When does it get run?

If you type

test me

it will run the commands in the string. You can define test whatever and have multiple test runs.

*clarification: type that in game

1 Like

(The lights suddenly switch on and Inform 7 jumps out shouting “Surprise!”)

4 Likes

Yeah, I forgot that too.

1 Like

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".
1 Like

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]".
1 Like

If we include a printed name, we can remove the room-name and directly understand the printed name property as describing a room-scenery.

1 Like

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.