Map item in Inform 7

I have been playing around with Inform 7, which is a design system for text adventures. What I really like it is the ease of development. Learning basics was easy as it uses a natural language interface.

Recently I had a need to create a working map. By working, I mean one that a player can meaningfully use to navigate towards a given point. Since I didn’t want to limit the system to a single map, but have an option to have multiple ones, I started by defining a new kind:

a mapping item is a kind of thing.
a mapping item has room called destination.
a mapping item has region called mapped area.

A mapping item is just a thing (item) with destination and mapped area added to it. Mapped area is used to define which region the map covers. Otherwise player would be able to navigate from areas that are not covered in the map.

The actual code for navigating:

Instead of examining a mapping item:
	if location of the player is the destination of the noun:
		say "[the description of the noun] You have arrived at the location marked in [the noun].";
	otherwise:
		if location of the player is in mapped area of the noun:
			let way be the best route from the location of the player to the destination of the noun;
			if the way is not a direction:
				say "[the description of the noun] Based on it, you wouldn't know which direction to go.";
			otherwise:
				say "[the description of the noun] It indicates that the correct direction to travel is [way]";
		otherwise:
			say "After consulting [the noun] for a while, you conclude that it doesn't have your current location on it.".

Examining a map will now tell player one of the following things:

  • He has arrived to the location marked to map,
  • He doesn’t know which direction to travel (usually this means there is no route to the destination),
  • He should travel to given direction,
  • The player is outside of the mapped area and can’t use the map.

The code assumes that there is a continuous path from the player location to the location marked in the map. If there is closed door in between, the map doesn’t work. By adding “, using doors” in the step where the best route is calculated, this can be fixed (in my case maps are for outdoor use, thus I don’t need it).

With these pieces, creating an old pirate map is easy:

the old map is a mapping item. The description is "This large map has been marked with locations of the pirate treasure." The destination of the old map is Waterfall Basin. The mapped area is Deserted Island Area.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s