Door to be unlocked by various keys. Possible?

Again a simple question I cannot find an answer for.

I am creating doors that can be unlocked by individual AND master keys.

Is it possible to unlock a door with multiple keys. The following does not work:

The matching key of Door XYZ is Key 1 and Key 2 and Key 3.

Ideas?

Have you tried separating them into their own objects? Key 1 unlocks Door XYZ. Key 2 unlocks Door XYZ. Key 3 unlocks Door XYZ.

This previous thread might help:
https://intfiction.org/t/a-door-with-2-keys/957/1

The topic has also come up on rec.arts.int-fiction, but I don’t remember precisely when.

Yes. Unfortunately it doesn’t work. The Parser tells me the same thing:

So no go. Bummer.

The link discusses a door with two keys (the I7 internal “backup key”). I would like to have more than two. If everything fails, I will stick with two. :slight_smile:

The rec.arts.int-fiction Thread in question is located here: http://groups.google.com/group/rec.arts.int-fiction/browse_thread/thread/6034176c6c824d61. They came up with this solution:

[code]Before unlocking Door XYZ with Key 1:
Now Door XYZ is unlocked;
rule succeeds.
Before locking Door XYZ with Key 1:
Now Door XYZ is locked;
rule succeeds.

Before unlocking Door XYZ with Key 2:
	Now Door XYZ is unlocked;
	rule succeeds.
Before locking Door XYZ with Key 2:
	Now Door XYZ is locked;
	rule succeeds.
	
Before unlocking Door XYZ with Key 3:
	Now Door XYZ is unlocked;
	rule succeeds.
Before locking Door XYZ with Key 3:
	Now Door XYZ is locked;
	rule succeeds.[/code]

This works.

BUT: Even if I have the fitting key, it is not recognized automatically as with usual doors. So this doesn’t seem ideal.

What can be done? Is there a way to create a workaround a la “if Key 1 is carried by the player…”?

You can set up a many-to-many relation between keys and doors, and then have a before rule that checks whether any of the carried keys has the relation to the door being opened. This shouldn’t be hugely difficult, especially if you have used relations before.

Could you elaborate? Also, this will unfortunately not fix the issue at the end of my last post, will it?

This should be reasonably close to what you want to have:

[code]“Keys” by Victor Gijsbers

A key is a kind of thing.

Fitting relates various keys to various doors. The verb to fit (he fits, they fit, he fitted, it is fitted, it is fitting) implies the fitting relation.

Hallway is a room.

The blue door is a door. It is south of Hallway. The Azure Room is south of blue door. The blue door is locked.

The red door is a door. It is north of Hallway. The Cherry Room is north of red door. The red door is locked.

The yellow door is a door. It is west of Hallway. The Apricot Room is west of yellow door. The yellow door is locked.

The red key is a key. The red key fits the red door. The red key is in Hallway.
The blue key is a key. The blue key fits the blue door. The blue key is in Hallway.
The yellow key is a key. The yellow key fits the yellow door. The yellow key is in Hallway.
The purple key is a key. The purple key fits the red door and the blue door. The purple key is in Hallway.
The green key is a key. The green key fits the blue door and the yellow door. The green key is in Hallway.
The orange key is a key. The orange key fits the red door and the yellow door. The orange key is in Hallway.
The white key is a key. Every door is fitted by the white key. The white key is in Hallway.

Before opening a locked door (this is the automatically unlock doors rule):
repeat with item running through keys carried by the player:
if item fits the noun:
now the noun is unlocked.[/code]
You need to implement some other stuff to make this work well, of course: explicit locking and unlocking.

This is indeed reasonably close. :slight_smile: Wow. It looks ridiculously easy. Well, obviously you are a pro here. :wink: I am learning (n00b!). Thanks for that.

With your final statement you mean if someone locks or unlocks a door by saying e.g. “unlock door with Yellow Key”? Is that what you are saying?

Yes, you need to make sure that locking and unlocking A with B work if B fits A.

Thanks. I think that with some experimentation I will be able to handle that. :slight_smile:

You helped me a great deal along the way. Thanks! :nerd:

Glad to be of assistance. :wink: Let me know if you get stuck.