Formatting Routes through Multiple Rooms

I’ve created a ‘going by name’ action as demonstrated in examples 306 and 307 of the recipe book (code below), and it works great. However, it becomes a bit much to play after a while, as the game prints the name and description of each room the player passes through to get to their final destination.

Is there a way I can either:

  • Use a temporary list of rooms to say something like “you make your way through the W, X and Y, ending up in… z”
  • Or just have it print the names of the rooms without their descriptions and contents.

I feel like this should be possible, but it’s a bit beyond my skill level. I realize that most of this command is still handled by the going action, and it is that which is causing all of this extra information to be printed.

I also wonder if there is another way of doing this that doesn’t require a loop.

Suggestions, other threads, or examples from the book are welcome. Thanks.


Include Locksmith by Emily Short.

Going by name is an action applying to one thing.

Understand "[any room]" as going by name.
Understand "go to/-- [any room]" as going by name.
Understand "[door]" as entering.

Check going by name (this is the can't go to the location rule):
	if the noun is the location:
		say "You are already there." instead.

Check going by name (this is the can't go to unvisited rooms rule):
	if the noun is not adjacent and the noun is unvisited:
		say "That noun did not make sense in this context." instead.

Carry out going by name:
	while the player is not in the noun:
		let that way be the best route from the location to the noun, using even locked doors;
		let destination be the room that way from the location;
		if that way is not a direction:
			say "You aren't sure how to get there from here." instead;
		try going that way;
		if the player is not in the destination, rule fails.

Have you seen the Approaches extension by Emily Short? That’s what it does - adds code supporting go to journeys, and creates summaries of them that it prints out after you take one.

-Wade

2 Likes

Sounds like exactly what I need. Much obliged

The extension is probably your best bet, and looking under the hood there will probably show you everything you know about how to implement it yourself, but in case it’s of interest, this is actually pretty easy to do if you just substitute “silently try” for “try” – that automatically suppresses reporting when you want stuff to happen without the player seeing what’s going on. Here’s the relevant bit of Writing With Inform.

Anyway, see below for a version of that (I added a toggle so the description of the ultimate destination does get displayed normally):

Carry out going by name:
	while the player is not in the noun:
		let that way be the best route from the location to the noun, using even locked doors;
		let destination be the room that way from the location;
		if that way is not a direction:
			say "You aren't sure how to get there from here." instead;
		if the noun is destination:
			try going that way;
		Otherwise:
			silently try going that way;
		if the player is not in the destination, rule fails.
2 Likes