r/Inform7 • • Oct 04 '26

Issues with location specific Understand rules when the player is sitting in a chair in a room...

Hello folks,

I've come up against a newbie problem I'm hoping someone can help with. I have a room called The Study. In the Study I have several things including a desk chair made functional as a chair with Emily Short's Postures. Things in the room have explicit names, but also 'printed name's. Each thing also has an Understand rule which tells inform to recognize the printed name as the thing when the player is in The Study, ie The Study-Desk has a printed name "Antique Desk". Understand "Antique Desk" and "Desk" as Study-Desk when the player is in The Study. I've also included the code below to make the items outside 'Desk-Chair' visible to the player:

After deciding the scope of the player:

if the player is enclosed by a Desk-Chair:

    place the location of the player in scope.

Things in the room are now available to the player when the player is in Desk-Chair *but* only when referenced using their explicit names. When the player is in the chair they can examine the 'Study-Desk' but not the 'Antique Desk'. How do I get inform to make the things available to the player by the terms defined with the Understand rule both when the player is in The Study and also when the player is sitting in Desk-Chair in The Study.

Thanks!

2 Upvotes

7 comments sorted by

2

u/Olaxan is a person in The Lab Oct 04 '26

I can't test this right now, but I suspect the problem is here:

Understand "Antique Desk" and "Desk" as Study-Desk when the player is in The Study.

Here, you use the conditional "the player is in the Study".

if the player is enclosed by a Desk-Chair:
    place the location of the player in scope.

And here, you use the more inclusive "the player is enclosed by a Desk-Chair".


I suspect your Understand rule would take effect properly if you wrote it the same way:

Understand "Antique Desk" and "Desk" as Study-Desk when the player is enclosed by The Study.

Alternatively:

Understand "Antique Desk" and "Desk" as Study-Desk when the location is The Study.

I don't like this nuance of Inform7 very much, but the "X is in Y" gotcha has tripped me up many times. I think Inform doesn't consider the player to be "in the Study" in your case, because they are currently "in the Desk-Chair." I don't even understand which relation it implies -- I just always write the most verbose, safe option to avoid the nuance.

Anyway, let me know if that fixed it, otherwise I can take a second look at it!

1

u/Dex21772 Oct 06 '26

Thanks, that did the job!

I altered the Understand rule to end with '...when the player is enclosed by The Study' and it now functions as expected when the player is in the chair. It's an interesting quirk that 'enclosed' possesses it's own over-riding scope rules, and that 'enclosed' can be expanded, presumably out to the region level to compensate, which is actually good to know because it presumably then applies to every container a player could be in within that region.

1

u/Olaxan is a person in The Lab Oct 06 '26

Glad to hear it! The reason this nuance annoys me is because I think the documentation (which is generally top-notch) is pretty vague about it; it spreads it out over many pages.

§3.25. The location of something; mentions "enclosed by".

§6.11. A word about in; mentions "is in" and the rarely used "is regionally in".


Anyway, for checking rooms I prefer:

...when the location of the player is The Room.

or just:

...when the location is The Room.

(shorthand for the player's location).

It's a faster query, because it just checks a variable, instead of performing a bounded relational lookup. A microsecond here, a microsecond there! :)

1

u/Shardworkx Oct 07 '26

Why are you saying

Understand "Antique Desk" and "Desk" as Study-Desk when the player is in The Study.

instead of just

Understand "Antique Desk" and "Desk" as Study-Desk.

1

u/Dex21772 Oct 09 '26

Because there are many locations with "Desk"s in the game and this lets the player use intuitive phrasing while in a location with one of the desks. Otherwise there could only ever be one "Desk" in the game.

1

u/Shardworkx Oct 10 '26

"Untitled"

Study is a room.

The Study-Desk is an object in Study. The Study-Desk has a printed name "Antique Desk". Understand "Antique Desk" and "Desk" as Study-Desk.

Library is a room. library is east of study.

The library-desk is an object in library. The library-desk has printed name "metal desk". Understand "metal desk" and "desk" as library-desk.

----

Untitled

An Interactive Fiction

Release 1 / Serial number 261010 / Inform 7 build 6M62 (I6/v6.33 lib 6/12N) SD

 

Study

You can see an Antique Desk here.

 

>x desk

You see nothing special about the Antique Desk.

 

>e

 

Library

You can see a metal desk here.

 

>x desk

You see nothing special about the metal desk.

 

>get desk

Taken.

 

>w

 

Study

You can see an Antique Desk here.

 

>x desk

(the metal desk)

You see nothing special about the metal desk.

 

>drop desk

(the metal desk)

Dropped.

 

>x desk

Which do you mean, the metal desk or the Antique Desk?

 

1

u/Shardworkx Oct 16 '26

Did you see my other message? Inform 7 handles what you want without needing to use "when player is in ..." on understand phrases.