Relations involving lists (and moving scenery)

Hey there. I’m using Inform 7 to make an interactive scene that involves sharing scenery objects between rooms. For instance, I’d like the player to be able to interact with a mailbox that they can see in two places: either while standing in the street before a house, or while standing in the front yard of said house. (However, upon entering the house, the mailbox should be out of play.) So far the way I’ve done this is by defining a relation:

Room sharing relates a list of rooms to various things.
The verb to be shared between means the reversed room sharing relation.
The verb to be shared among means the reversed room sharing relation.

Then I can say:

The mailbox and sidewalk are shared between {the Street, the Front Yard}.

Or even:

The roof is shared between {the Street, the Front Yard, the Back Yard}.

The reason for using a list as the left-hand side of the relation is that in order to share something, that thing must be shared between/among more than one room. It wouldn’t be right to say:

The Front Yard shares the mailbox and sidewalk.

or, conversely:

The mailbox and sidewalk are shared between the Front Yard.

Otherwise I would have said (a list of -> various):

Room sharing relates various rooms to various things.

So, now, in order to implement the sharing, I want to have the game automatically move the shared things to the rooms-that-are-doing-the-sharing. Specifically, when the player moves from one room to another, and there are things in the first room that are being shared with the second room, I want the game to automatically move those things from the first room to the second room.

Moving objects isn’t difficult; what’s difficult is figuring which things are shared. I started by simply having the game list which things are shared as the player moves to different rooms, and I came up with this:

After going from a room (called origin) to a room (called destination):
	say "Going from [origin] to [destination].";
	let sharing rooms list be the list of list of rooms which the room sharing relation relates;
	repeat with sharing rooms running through the sharing rooms list:
		let shared things be the list of things to which the sharing rooms relates by the room sharing relation;
		if the origin is listed in the sharing rooms and the destination is listed in the sharing rooms:
			repeat with thing running through shared things:
				say "[The thing] is shared between [the origin] and [destination].";
				[Presumably at this point we can move the thing from the origin to the destination.]

The problem is that, other than the initial “Going from” line, this prints nothing. The only reason I can think of (based on my background in programming) is that when Inform is trying to figure out the list of things to which the sharing rooms relates by the room sharing relation, it does a shallow equivalence match based on the input and not a deep equivalence match. That is to say, if you say

The mailbox and sidewalk are shared between {the Street, the Front Yard}.

Inform stores {the Street, the Front Yard} in the relation, and so when you ask what instances of that relation have {the Street, the Front Yard} as the left-hand side, it’s going to give you nothing, because {the Street, the Front Yard} !== {the Street, the Front Yard}. Then again, I have no clue as to how relations are implemented in Inform, so that is just an educated guess.

Has anyone else run into this problem? Alternately, does anyone have another idea as to how I could accomplish the task of moving scenery objects automatically from one place to another?

List relations are an interesting thought, but I think you’re reinventing the wheel somewhat—look at §3.9 in the manual, on “backdrops”.

1 Like

(For future reference, though, I’d recommend using a one-to-many relation instead of trying to relate to lists. Something like this:)

Place-sharing relates one thing to various rooms. The verb to be shared between means the place-sharing relation.

The grass is shared between the field and the yard.

When Daybreak begins: now the Sun is shared between all outdoor rooms.

You know… I swear I tried out backdrops before. They do seem to work perfectly, so now I’m not sure why I thought they wouldn’t. And thanks for the suggestion about simplifying the relation. I knew there had to be a less painful way of accomplishing that.