What does this code from 'Bronze' do?

So I’m dissecting bit’s and pieces of ‘Bronze’ to help me get my first test game running, and fairly quickly this bit of code is introduced:

To say (item - a thing) direction: let place be a random room; let the place be the other side of the item; if the place is visited, say "[way through the item] to [the place in lower case]"; otherwise say "[way through the item]".
And this:

To decide what direction is the way through (threshold - a door): let far side be the other side of threshold; let way be the best route from the location to the far side, using even locked doors; if way is a direction, decide on the way; decide on inside.

I’m not sure what exactly the code is doing, and whether I need it for what I’m doing.

Could someone please explain it?

This is part of code for printing the description of doors. It goes with this line earlier in that section:

The initial appearance of a door is usually "Nearby [an item described] leads [item described direction]."

So, let’s say the player is in the Antechamber and they could go west through a wooden door into the Chamber. The game will print the initial appearance of the wooden door in the room description. For this, the “item described” is the wooden door. So to evaluate “[the item described direction]” we need to evaluate the first code block you quoted, with the argument “item” set to this item described (the wooden door).

Now the first two lines of that code block set “the place” (a temporary variable) to the other side of the wooden door, that is The Chamber. Then, regardless of which branch of the “if” we go through, we have to evaluate “way through the item,” which calls the second code block with the argument “threshold” set to the item, which was set to the wooden door.

The second code block now does this:
“far side” gets set to the other side of the wooden door, which is the Chamber;
way gets set to “the best route” from the location (the Antechamber, where the player is) to the Chamber, using even locked doors, which is west;
since west is a direction, the function call returns west.
This all is basically a way of asking “Which direction is the door we’re talking about from the room the player is in?”

OK, back to the first code block. There’s a test here for if “the place” (the Chamber) is visited, which is a built-in property that determines whether the player has been there. If the Chamber has been visited, it says “[way through the item] to [the place in lower case]” which is “west to the chamber”. If not, it just says “[way through the item]” which is west.

So, basically, this means that the room description will say “Nearby a wooden door leads west” if you haven’t been to the chamber, and “Nearby a wooden door leads west to the chamber” if you have been to the chamber and so what’s there. And it automates this for every door. So you don’t need this if you aren’t trying to automate the descriptions of doors in this way.

BTW, there are a couple of things here that I think may have been necessary for older versions of Inform, or that I wouldn’t do (like I know how to code Inform better than Emily Short, ha). One thing is that the first code block is something that applies only to doors, since “other side” is a property that only makes sense for doors. So I’d change “(item - a thing)” to “(item - a door)” to make sure I don’t try to invoke this with something that isn’t a door. Also, I don’t think “let place be a random room” is necessary; it should be possible to use the next line to set the place directly to the other side of the item.

This bit particularly confused me! Thanks Matt.

On the point, Mrs. Short can update his sources to current version of Inform 7 ? remain good code example and tutorials, IMVHO.

Best regards from Italy,
dott. Piergiorgio.

Another thing: it seems that “[the place in lower case]” no longer compiles. It has to be “[the printed name of the place in lower case]”.