Listing available directions from current location

Is there a simple way to list available directions from the current location.

So far I have come up with this:

repeat with that_way running through directions: let that_room be the room that_way from the location; if that_room is a room: say "[that_way] ".
Which works, but is there a simpler way?

I have a feeling there must be something built in, like [list of available directions],
but that particular one does not compile and I can’t find the right syntax for it.

And another thing. Can anyone recommend a simple way to make some directions “secret”
so they won’t show up in the listing I’m asking about - either for the example code
I gave above, or for some other more elegant solution that you suggest?

There’s an extension that already exists which does pretty much all you mentioned: Exit Lister by Eric Eve.

Download it, install it to Inform, then add the line:

“Include Exit Lister by Eric Eve.” to your source.

If you add this to your game and do nothing else, obvious exits will be listed in the status bar and indicated as visited or unvisited, but there are lots of customisations you can make - just read the docs in the extension. The player can also type ‘exits’ to see a list of them. There’s code in there to do the secret room type stuff, too.

If you’re getting into Inform 7, it can be worth browsing around in the Inform 7 extensions pages to see what kind of stuff people have already written pre-packaged code for.

  • Wade

However, this is only done on a room or door basis not on a direction basis, so you can stop a room or door from showing on the exit listing but not individual directions from that room or door.

The documentation does mention a way to do that:

Every turn: if the location is the Short Path, now the Sunken Garden is apparent; otherwise now the Sunken Garden is not apparent.

True. I’ve used it a lot while doing my latest game.

I guess it does mention that way of doing it, but it seems hackish. Also, it could easily get messy and complex if you have many rooms and complex conditions determining whether each room is transparent.

The extension is set up so as to list only the those directions from the location that leads to an apparent room or door. So if the room or door is not apparent, it will not actually list the direction of that room or door either.

(And one wouldn’t really make a direction as such not apparent, for then exits in that direction wouldn’t ever be listed in any room. I mean, the south from one room is not a different south from the south in any other room, is it? So, if the south as such were a not apparent direction, no southward exits would be apparent anywhere in the game.)

I’m not sure I understand climbingstars original point, but my usual way to set up a secret room B next to A (with no door objects involved) is this:

  1. Place B east of A as per usual when constructing the rooms.
  2. Define B as not apparent - Now the exit to B doesn’t show when you’re in A, but the player could still walk into room B if they tried east.
  3. Add an instead rule to cover point 2:
    EG. Instead of going east in A when B is not apparent: say “You can’t go that way.”

Now when the player pulls a lever somewhere else that opens the way to room B, I just say ‘Now B is apparent’ and I’ve done everything needed to make the room accessible and to make the way to it appear in the exit lister.

  • Wade

I probably stole this from somewhere, but this has worked out pretty well for me. I have it run automatically after room descriptions are printed.

[code][Typing “exits” will list each exit available, and if visited, the name of the room.]
Saying exits is an action applying to nothing. Understand “exits” or “say exits” or “list exits” as saying exits.
Carry out saying exits:
Let place be location;
Let exitcount be 0;
say "List of available exits: ";
repeat with way running through directions:
let place be the room way from the location;
choose row with a heading of the way in the Table of Direction Abbreviation;
if place is a room:
say “[if exitcount is not 0], [end if][shortcut entry][if place is visited]: [place][end if]”;
now exitcount is exitcount + 1;

Table of Direction Abbreviation
heading shortcut
north “N”
northeast “NE”
northwest “NW”
east “E”
southeast “SE”
south “S”
southwest “SW”
west “W”
up “U”
down “D”
inside “In”
outside “Out”[/code]

This shows up as “List of Available Exits: N, W: The Garden, E: The Tea Room”, if North is unexplored.

I think that was exactly the limitation that climbingstars brought up. It’s the destination “room” that is set to not apparent, not the “direction” from the origin room.

If I have understood the discussion correctly it seems if you make the direction from A to B “secret” (ie. make it not appear in the exit lister) in this way, you get the undesired side effect into the bargain of directions into B from other locations becoming secret at the same time. And you need to resort to a bit of hacky trickery (or is it tricky hackery ?) to work around and cancel out the undesired effect.

Or am I missing something?

You can’t have an exit in any direction from a room without having a door or a another room in that direction. In a sense there are no exits to the Inform language, there are only rooms and door in this or that direction.

If you use the Exit Lister, then in a room with a door to the south and a room to the north, the status line will by default say «Exits: north south». If you make the door ‘not apparent’, the status line will say “Exits: north”.

Consider this.

Room 2 is east of Room 1 and west of Room 3.

If you were to make Room 2 not apparent, the exit listings for both Room 1 and Room 3 would show no exits. There is no direct way of having the direction to Room 2 show up in either Room 1 or Room 3 but not both without resorting to constantly checking the player’s location and flipping between apparent and not apparent.

I guess a non-apparent door is the way to do it.

Other routes into that destination will not be affected ie. no unwanted side effects, and no special hackery needed.
And I suppose a door can be made to appear as an ordinary movement between rooms. The player doesn’t even need to be told, or given a clue that it’s there.

I’m thinking about writing a small example with the different alternatives to get a feeling for how it is done.

Well, that was in fact exactly the kind of situation that I DID consider, and did describe in the post you are quoting.

But putting a door between 1 and 2 should solve it without needing the constant checking and flipping, shouldn’t it?
You make the door non-apparent, not the room that it leads to.

You’re right, of course. I completely overlooked that.

You can amend the definition of ‘apparent’ from within your source text so as to make Eric’s Exit Lister behave as wanted. Try this:

Include Exit Lister by Eric Eve.

Priestholeness relates one room to various rooms. [EDIT. Read: Priestholeness relates VARIOUS rooms to various rooms.]
The verb to be hidden from view in implies the priestholeness relation.

Definition: a room is apparent if it is not hidden from view in the location.
Definition: a door is apparent if it is not hidden from view in the location.

 [Now, use 'hidden from view in' rather than 'apparent' when you want to hide an exit. The code above translates it to the word 'apparent', that the extension already uses.]

The Place is a room.
North of the Place is Another Place.
The Hideaway is south of the Place. The Hideaway is hidden from view in the place.
The Inner Chamber is south of the Hideaway. 
[/code](Or at least, so I think—unless I'm overlooking something else.)

EDIT: There was—the relation should be many–many, obviously. So, read [code]
Priestholeness relates VARIOUS rooms to various rooms.

You still have the same problem, but on a smaller scale. Consider this.

The big door is a door. The Big Door is east of Room 1 and west of Room 2.

If you were to make the big door not apparent, the exit listings for both Room 1 and Room 2 would still show no exits. There is still no direct way of having the direction through the big door show up in either Room 1 or Room 2 but not both without resorting to constantly checking the player’s location and flipping between apparent and not apparent.

This could be solved by using the Deluxe Doors extension, which uses pairs of one way doors but a minor point is that it does mess up the index map. This can be fixed manually though.

That does work quite nicely.

Coincidentally, I’m working on an exit listing extension that allows the listing and unlisting of specific exits of specific rooms at will using phrases like this.

[code]unlist the north exit from the sunken garden;

list the north exit from the sunken garden;[/code]

This should allow for a highly dynamic exit listing.

Mmm, didn’t think of that. But what about this:

[code]The big door is a door. The Big Door is east of Room 1 and west of Dummy-Room-1-East.

Instead of going to Dummy-Room-1-East: move player to Room 2.

Ah, Now I see I wouldn’t even need a door to do it this way.

[code]Dummy-Room-1-East is east of Room 1.

Instead of going to Dummy-Room-1-East: move player to Room 2.
Then I’d set up a similar dummy room for getting from room 2 to 1 and then each of the dummy rooms could be made apparent or non-apparent individually.

But the smartest solution is probably to wait till your exit listing/unlisting extension is out.
Sounds like it could come in useful once in a while.