Dynamic room names

See code below. I’m thinking I may have a lot of buildings. So listing them all by name is going to require a lot of code and will be inefficient. Using a dynamic room name would be useful.

This is my current experiment:

Building is a kind of thing.
A building is usually scenery.

The small-house is a building.
The entrance-of-small-house is a room.

Going by name is an action applying to one thing.
Understand "go [any building]" as going by name.

Check going by name:
	if the noun is the small-house:
		move the player to the entrance-of-small-house;
		stop the action;
	[and so on for many buildings...]

I’d like to do something like this instead:

move the player to the entrance-of-[the noun]

Inform can’t do dynamic variable lookup in this sense.

The most straightforward way to do this is to have a property on buildings:

A building has a room called the entrance.

And define the entrance for each building. Then you can talk about “the entrance of the noun”.

Thanks. So, in my example a building is a thing. If I understand you correctly, you’re saying the thing can have a property, and the property can be a room?

My understanding is that each room must have a unique name. If I have multiple buildings, they can’t all have a room called “the entrance”. Am I misunderstanding something there?

See chapter 3 and 4 about “properties”.

A building is a kind of thing.

A building has a room called the entrance.

The small-house is a building.
The entrance-of-small-house is a room.

The entrance of the small-house is entrance-of-small-house.

Check going by name:
	move the player to the entrance of the noun.

In this situation the entrance is not the name of a room, it is the name of a property. The entrance-of-small-house (a room name) could be the entrance (property name) of the small-house, while the entrance-of-large-house could be the entrance of the large-house.

ok, got it. Sounds good.

Thanks for pointing me in the direction of the documentation chapters I need. New to Inform so wasn’t aware that properties are the solution here. I’ll go spend some time in the docs now. :slight_smile:

Thank you both for solution and clarification.

Hi, You might also want to consider declaring your buildings as regions (which are the natural kind of object to contain rooms in Inform) rather than things. See the documentation in 3.4.

Yeah I’ve been exploring regions. I got quite far with that approach but couldn’t quite find a way to implement what I wanted. Possibly that’s due to my lack of experience with Inform. I may still define buildings as regions for other purposes, but with regard to the player navigating to the building in the first place, having one location where all the buildings are present (as scenery) and then accessing them with Go Shop, Go Library etc works well.

The only niggle I have right now is that if I do this:

Understand "in [any reachable building]" as going by name.

When there’s more than one building present, the disambiguation prompt is “What do you want to in?” so I need to intercept that and modify it. I presume that’s a standard response I can modify. I’m still confused about how exactly to work with responses, but that’s a question for another time and I haven’t fully worked through the documentation yet. Edit: Chapter 14 sorted that out fairly quick.