Can't understand (I7)

I am trying to get Inform to understand “here” as the location but the code Understand [here] as the location. will not work.

That’s a really odd coincidence–I just tried a similar piece of code this morning, with the same result. I’m not sure why Understand "here" as the location. doesn’t work, but I imagine it’s related to the fact that the location is a room that varies rather than a single one. It seems like there should be a way, though…

The location isn’t normally in scope anyway. The default response to actions like X KITCHEN or SMELL KITCHEN (even when you are in the kitchen) is your trusty friend Good Old “You can’t see any such thing.”

Ooh, I think I’ve got it! Understand "here" as a room when the player is enclosed by the item described.

That will accept “here” as a room-synonym. However, as Felix said, rooms are normally not in scope, so you can’t refer to them anyhow.

(If you change the scope rules to put the current location in scope, you could just add “Understand “here” as a room.” You wouldn’t need to qualify that because only one room would be in scope at a time.)

I hadn’t realized the location wasn’t in scope. That’s good to know.

It was for debugging purposes. The code I used was to tell the distance between two rooms, Including the one I am in. There for I needed “here” to work.

If the action was otherwise defined with room tokens, the main problem (along with the “location” thing) was that you need “here” with quotes instead of [here] with brackets. Brackets outside text is considered a comment and ignored by the compiler.

It sounds like you’ve got this working, but just in case, here’s the whole bit:

The Kitchen is a room.

The Bathroom is east of the Kitchen.

Section - Distance test - not for release

Room-measuring is an action out of world applying to two things.
Understand "measure [any room] to [any room]" as room-measuring.

Understand "here" as a room when the item described is the location.

Carry out room-measuring:
	say "The distance from [noun] to [second noun] is, um, seven."

(I used “…when the item described is the location” as the understand condition. This is faster than “encloses”.)

The [here] was a mistake. I most sincerely apologize for whatever inconvenience I caused you people. And whatever spam bots are reading this right now. and the government. and anything else. including alien life forms.

Hey, is there any particular reason why the location is not in scope? You can just do something like this:

After deciding the scope of the player: 
    place the location in scope.

instead of examining the location: try looking.

I guess this means that rooms can be used more like other objects. Wouldn’t it make sense if the player can do stuff to the room? Like examine it, search it, and so on?

Well, something like this perhaps:

After deciding the scope of the player: 
    place the location in scope.

instead of examining the location: try looking.

Understand "here/room/location" as a room when the player is enclosed by the item described.

check taking a room (this is the block taking rooms rule): 
	say "You can't take [the location].";
	stop the action;
	
The can't search unless container or supporter rule is not listed in any rulebook.

check an actor searching (this is the can't search unless container or supporter or room rule):
	if the noun is not a container and the noun is not a supporter and the noun is not a room:
		stop the action with library message searching action number 4 for the noun.

carry out searching a room (this is the deafult searching rooms rule):
	say "You find nothing notable.";

So this will let you do things like this:

carry out searching the library for the first time:
	say "Oooh. You find a book. In a library, of all places.";
	now the Necronomicon is in the library;
	do nothing instead;

License: By using this code you agree not to misuse this code to force players to randomly search rooms to find important information without first hinting that there is a reason to search the place.

It would be simpler to do something like this:carry out searching the library for the first time: now the Necronomicon is in the library; say "Oooh. You find a book. In a library, of all places." instead;
P.S. What is a Necronomicon?

“stop the action” also has the same effect as “do nothing instead,” doesn’t it?

Yes. Just “stop” is equivalent here as well.

For the low cost of that one question, you get 3 necronomicons!

youtube.com/watch?v=2xB5GBvOqEY