Alternating Room Descriptions based on Approach Direction (Apologies)

Hello again. I know this question has been answered, specifically with reference to a part in Zork if memory serves. Will someone help me find it again (I’ve tried for a while now) or remind me how to change a room description based on the direction the room is approached from?

For example, imagine coming out of the front door of the house into the front garden as opposed to coming in the front gate into the same front garden. The descriptions would be different, one dominated by the house and the other dominated by the gate and street beyond.

Two different versions of the same room with the same displayed name? I have done that with I6 and it seems to provide the effect I’m looking for.

I am sure there is a more elegant way than mine though.

Here’s a solution:

"[if the location was X] X text [else if the location was Y] Y text [else] Z text"

Thanks for suggesting that. I thought it was a good solution but I recalled reading an example which dealt with it more simply.

The example I’m thinking of had a mountain path in it but maybe I’m misremembering.

Thanks for the reply. That looks more like what I recall. I went around and around with that syntax using “last” and “previous”. It’s the “was” that does the trick.

Sometimes I can’t believe it’s the simplest grammatical solution that takes care of it.


I’ve used that in the past also but I think I read an example that showed you can achieve the effect without needing to make two rooms. maybe I’m misremembering though.

1 Like

What do you mean by this? It sounded like having more than one room was the point of your question (eg. coming from the Street to the Garden or from the Foyer to the Garden) - can you clarify?

As I read it, the point is to avoid having to make and juggle two separate Garden rooms–that is, the OP wants to have a single room that alters its description based on the direction of approach, rather than making a room called “Garden (when approaching from Street)” and then swapping it out for “Garden (when approaching from Foyer)” after passing through it. (Which is a possible, though unnecessarily complicated, solution to the problem.)

1 Like

You’re welcome :grinning:

The relevant stuff is rather cursorily discussed, with examples, in section 9.13 of the Documentation. This and the other temporal conditions discussed in the subsequent sections of Chapter 9 are unusual and powerful features of Inform 7, and possibly underappreciated on account of being given rather passing mention in the official docs. They save having to invent, update and keep track of a load of flag variables to monitor changes in game state.