New kind of key?

I would like to create a new kind of key in my game, called a keycard. It would work just like a key. So there might be a Red Key or a Green Keycard as objects. Both work like keys.

Is this possible?

Or am I better off just making the Red Key and Green Keycard keys (i.e. Green Key) and change the printed name of the Green Key to Green Keycard? (Or is this even possible?)

Thanks.

Inform 7 doesn’t define a key kind by default, so “new kind of key” and “work just like a key” don’t really mean anything.

Inform does define a ‘matching key’ property on doors. You can say "The matching key of is " or " unlocks " to set the matching key for a door. Anything set as the matching key for a door is considered by the ‘unlocking it with’ action to be a key, regardless of its kind, so long as it can be picked up. (For amusement, try defining a person as the matching key of a door. Then, PURLOIN and UNLOCK DOOR WITH .)

You might still want to define a keycard kind so that you can write general rules about keycards.

A keycard is a kind of thing.
Understand "key" or "card" as a keycard.

To swipe is a verb.
After unlocking a door with a keycard when the action is not silent:
	say "[We] [swipe] [the second noun], and [the noun] [unlock] with a click."

After closing an unlocked door:
	now the noun is locked;
	if the action is not silent, say "[We] [close] [the noun], and [they] [lock] with a click."

The blue door is a locked door. It is north of Start Room and south of Blue Room.
The blue keycard unlocks the blue door.

The red door is a locked door. It is south of the Start Room and north of Red Room.
The red keycard unlocks the red door.

The red keycard and the blue keycard are keycards carried by the player.

Does the player mean unlocking an unlocked door with: it is unlikely.
Does the player mean unlocking a door (called D) with the matching key of D: it is likely.

Test me with "n / unlock blue door / g / n / close door / s / unlock door / s / unlock door / s / close door / unlock door / n."

Thanks vlaviano.

Say, why are the last two lines necessary?

They’re not strictly necessary, but they help the parser to make inferences during disambiguation so that it can ask the player fewer “which do you mean?” questions.

The first line says that if the player asks to unlock a door and there are multiple doors available, prefer a locked door to an unlocked one.

The second line says that if the player wants to unlock a door and doesn’t specify with what, prefer the object that’s the door’s matching key.

See §17.19 for more on this topic.