Spielerando

Key Items

Key items are the few things the story needs, such as a key that opens one particular door. They sit in a pocket of their own, so a full bag never blocks one, and they cannot be dropped or sold. A used-up key never comes back, and a check finds doors that can no longer be opened.

Also called: Quest items, Story items, Keys and locks, Unlock items.

A fox pilgrim in a green hooded cloak turns a tall golden key in the keyhole of a tall blue door, and light streams out as the door swings open, in the style of stained glass.
Lantern Psalter, an invented pilgrimage puzzle adventure. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Key Items" to my game.

What it should do: Key items keep the story from breaking. The player can never lose, sell or fail to pick up the one thing that lets them go on.

Use these starting values:
- pocketSize: 16 keys

Watch out for these common mistakes:
- A full bag blocks the key: Tell your AI: keep key items in a pocket of their own that the bag limit does not touch.
- The key can be sold or dropped: Tell your AI: refuse to drop, sell or throw away any key item, and say why.
- The same key is picked up twice: Tell your AI: remember every key that was ever taken or used, and ignore a second pickup of the same key.
- A one-use key is needed by two doors: Tell your AI: run the check that lists shut doors whose key is gone. Give each one-use key a single door, or make the key reusable.
- The key is spent by a failed try: Tell your AI: only spend a key after the door has really opened.
- Keys matched by name: Tell your AI: give each key an id that never changes, and match doors to keys by id.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

Key items keep the story from breaking. The player can never lose, sell or fail to pick up the one thing that lets them go on.

Good starting values

ValueStart withWhat it changes
pocketSize16 keysHow many keys the pocket holds. It is separate from the bag, so a full bag never blocks a key. Set it above the number of keys in the whole game: a key that does not fit is left in the world, and the player may not find it again.

What usually goes wrong

A full bag blocks the key

The player reaches the key with a full bag, and the game treats the key like any other item. The pickup fails, the key stays on the floor, and the player walks on without knowing they missed it. Later the door cannot be opened.

Fix: Tell your AI: keep key items in a pocket of their own that the bag limit does not touch.

The key can be sold or dropped

The player sells the key, throws it away, or leaves it behind in a chest. The door can never be opened and the story cannot go on.

Fix: Tell your AI: refuse to drop, sell or throw away any key item, and say why.

The same key is picked up twice

A key respawns after reloading, or the player walks back into the room. Now there are two copies. A used-up key even comes back and opens its door a second time.

Fix: Tell your AI: remember every key that was ever taken or used, and ignore a second pickup of the same key.

A one-use key is needed by two doors

A key is used up by the first door it opens, and a second door also needs it. If the player opens the wrong one first, the other can never be opened.

Fix: Tell your AI: run the check that lists shut doors whose key is gone. Give each one-use key a single door, or make the key reusable.

The key is spent by a failed try

The player tries the key on a door it does not fit, or on a door that is already open, and the game still uses it up.

Fix: Tell your AI: only spend a key after the door has really opened.

Keys matched by name

The door checks the key by the name shown on screen. Renaming it, or translating the game, makes every door stay shut.

Fix: Tell your AI: give each key an id that never changes, and match doors to keys by id.

How to check it works

Works well with

Common questions

how do i stop the player from losing a quest item

Keep quest items in a pocket of their own, and refuse to drop, sell or throw them away. A key that cannot be lost cannot leave the story stuck.

what do i tell my ai to add keys and locked doors

Paste this: Add key items in their own pocket, separate from the bag. Each door names the id of the key it needs. Keys cannot be dropped or sold, a key is picked up only once, and a key is used up only when the door really opens. Add a check that lists shut doors whose key is gone.

should a key disappear after it opens a door

Only if no other door needs it. A reusable key is the safe default. If a key is used up, remember that it was, so it cannot be picked up again, and run the check for doors that can no longer open.

what is a soft lock in a game

It is a place where the player cannot go on and cannot go back, and nothing tells them. A shut door whose key is gone is the most common one, so check for it before the game ships.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it