Equipment Slots
Equipment slots are named places on a character, such as head, body, two hands and two rings, and each takes only one kind of item. Equipping sends the old piece back to the bag. A two-handed weapon needs both hands. If the bag has no room for the swap, nothing happens and nothing is lost.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Equipment Slots" to my game.
What it should do: Slots turn a pile of gear into a set of choices: one helmet, one weapon, a pair of rings. The player decides what to wear, and the game always knows what is worn and where everything else is.
Use these starting values:
- bagSlots: 10
Watch out for these common mistakes:
- The old item has nowhere to go: Tell your AI: work out everything that has to leave first, check the bag can take all of it, and only then change anything. If not, refuse the whole swap.
- Two-handed weapon with a shield: Tell your AI: a two-handed weapon always clears the off hand, and a shield always clears a two-handed weapon from the main hand. Both come back to the bag.
- A swap that needs no spare room: Tell your AI: the place the new item leaves counts as free. Only refuse when more items come off than there are places.
- Two rings: Tell your AI: when no slot is chosen, use a free matching slot first. Only when all are taken, replace the first.
- An item put in the wrong slot: Tell your AI: check the item's kind against the slot before anything moves, and say the slot does not fit.
- Gear in the bag counts as worn: Tell your AI: add up the worn slots only.
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
Slots turn a pile of gear into a set of choices: one helmet, one weapon, a pair of rings. The player decides what to wear, and the game always knows what is worn and where everything else is.
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| bagSlots | 10 | How many places the bag has. Ten leaves room for a few spares and still fills up. With one place, a plain swap still works because the new item leaves its place for the old one. |
What usually goes wrong
The old item has nowhere to go
The bag is full and the player swaps a big weapon in. If the game puts the new item on and then looks for room, the shield that had to come off disappears.
Fix: Tell your AI: work out everything that has to leave first, check the bag can take all of it, and only then change anything. If not, refuse the whole swap.
Two-handed weapon with a shield
The player holds a shield and equips a two-handed weapon. If only the main hand is checked, the character swings a greatsword and holds a shield at once.
Fix: Tell your AI: a two-handed weapon always clears the off hand, and a shield always clears a two-handed weapon from the main hand. Both come back to the bag.
A swap that needs no spare room
The bag is completely full and the player swaps one helmet for another. A check that wants one free place refuses a swap that would work fine.
Fix: Tell your AI: the place the new item leaves counts as free. Only refuse when more items come off than there are places.
Two rings
With two ring slots, the game always uses the left one. The second ring replaces the first one, and the right slot is never used.
Fix: Tell your AI: when no slot is chosen, use a free matching slot first. Only when all are taken, replace the first.
An item put in the wrong slot
A dropped item or a clicked slot says body, but the item is a ring. A game that trusts the slot puts a ring on the body and the power adds up wrongly.
Fix: Tell your AI: check the item's kind against the slot before anything moves, and say the slot does not fit.
Gear in the bag counts as worn
The total power is summed over the whole bag by mistake, so the player gets stronger just by carrying a better sword.
Fix: Tell your AI: add up the worn slots only.
How to check it works
- A character wearing a cap and a bag holding a better iron helmet. you equip the iron helmet: the iron helmet is worn and the cap sits in the bag place the helmet came from.
- A helmet in the bag. you try to put it on the body slot: the game says it does not fit and nothing moves.
- A character holding a sword and a shield, and a two-handed greatsword in the bag. you equip the greatsword: the greatsword is in the main hand, the off hand is empty, and the sword and the shield are in the bag.
- A character holding a two-handed greatsword and a shield in the bag. you equip the shield: the shield is in the off hand and the greatsword goes back to the bag.
- A bag of three places that is full, and a character wearing a sword and a shield. you equip a two-handed greatsword from the bag, which would send out two items: the game says the bag is full and nothing changes. A one-for-one swap in a full bag still works.
- A character wearing mail armour. you take it off with a full bag, and then with a free place: the first is refused and the armour stays on; the second puts it into the bag.
- Three rings in the bag and no ring worn. you equip them one after another without choosing a slot: the first goes left, the second goes right, and the third replaces the left one, which returns to the bag.
- A character wearing a helmet of power 2, a sword of 5 and a shield of 3, with a spare sword of 50 in the bag. you read the total: it is 10, and 7 after the shield comes off.
- A bag with one item. you equip an empty place, a place that does not exist, a place number with a fraction, or unequip an empty slot: the action is ignored and nothing changes.
Works well with
Needs: Inventory System.
- Health and Damage: Recalculate after every equip and unequip, so a stale total never decides a fight. Work out the total from the worn items first, then use it in the damage calculation.
- Item Stacking: Never let a whole stack of ten rings go onto one finger. Worn items are single pieces. Take one from the stack before it goes to a slot.
- Weight Limit: Otherwise putting on armour appears to make the player lighter. Worn items still weigh something. Count the bag and the worn slots together.
Variations: Hotbar.
Common questions
what do i tell my ai to add equipment slots
Paste this: Add equipment slots for head, body, two hands and two rings. Each slot takes one kind of item. Equipping sends the old item to the bag, a two-handed weapon clears the off hand, and if the bag has no room for what comes off, refuse and change nothing.
how do equipment slots avoid losing items
Treat a swap as one step. First work out what must come off, then check the bag can take it all, and only then change anything. An item is always either in the bag or on the character.
how many equipment slots should a game have
Fewer than you think. Every slot is a choice the player must make again with each new find. Four to six is plenty for most games, and more slots only help if each one changes how the character plays.
can two items go in the same slot
Not unless you build it on purpose. The usual way to get two weapons is two slots, or a quick swap between two sets, so each place still holds exactly one item.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 13 tests pass on the reference code.
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