Obtaining the name of an object from one of its properties

Hello friends. New question for you.

I am designing doors that open with a key fob. There are a bunch of them, and the doors are all defined (complicated, two different pieces of scenery that look different from each side, etc.).

They all have the same property of having a little security pad associated with them, so that when the player holds the key fob up to the door, it opens. But I also want them to be able to hold the key fob up to the pad that’s associated with that door, and know which door to open.

So I’ve defined a fobdoor as a kind of door that is also scenery, and then I have this line.

A fobpad is a kind of thing.  One fobpad is part of every fobdoor. 

My question is this:

Is there any way to determine, when somebody is interacting with a given fobpad, which door it is associated with?

Something like (this is a not-it example)

Instead of doing something to a fobpad, try doing it to the associated fobdoor instead.

I also tried the more cumbersome:

Instead of doing something to the fobpad of a fobdoor (called the noun): try doing it to the noun.

But the compiler doesn’t like that either.

Any suggestions would be much appreciated!

Try something along the lines of:

Check taking a fobpad (called the portion):
	if the portion is part of a fobdoor (called the whole):
		try taking the whole instead.

If you want to do a bunch of actions at once, you can try:

Before taking or dropping or [rest of commands] when the current action involves a fobpad (called the portion):
	if the portion is part of a fobdoor (called the whole):
		if the portion is the noun, now the noun is the whole;
		if the portion is the second noun, now the noun is the second whole;
		try the current action instead.

Too many of these tend to slow compilation way down, though.

1 Like

If noun is a fobpad, you can get the value of the fobdoor of which it’s a part with: the holder of the noun.

But this is probably what you really want:

A fobdoor is a kind of door.
A fobpad is a kind of thing.
a fobpad is part of every fobdoor.

Understand "[something related by incorporation]" as a fobdoor.

I’ll note that the fobpad isn’t a property of the fobdoor, the fobdoor relates to its fobpad by the incorporation relation. There is also a straightforward way to have the parser recognize things by their properties; see “Understanding by Property” in the Understanding chapter in Writing with Inform. (This doesn’t work, though, for properties whose kind is an object or subkind of object.)

1 Like