Crafting System
A crafting system turns items into other items with recipes. Check the whole recipe first: add up each ingredient across all its lines, make sure the result fits, then take and give in one go. A craft either happens exactly as written or changes nothing, so nothing appears from nowhere or gets 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 "Crafting System" to my game.
What it should do: Crafting gives the things players gather a use, and lets them decide what to make from what they have.
Use these starting values:
- maxStock: 99 items
Watch out for these common mistakes:
- A recipe lists an item twice: Tell your AI: add up the lines for each item before comparing with what the player has.
- A full stock eats the result: Tell your AI: check that the result fits before anything changes, and count the room the ingredients free up.
- Taking ingredients one at a time: Tell your AI: check everything first, then do all of it at once.
- A recipe that gives back what it takes: Tell your AI: work out the room from what the player will have after the ingredients are gone.
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
Crafting gives the things players gather a use, and lets them decide what to make from what they have.
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| maxStock | 99 items | The most of one item the player can hold. A craft whose result would go over it is refused. |
What usually goes wrong
A recipe lists an item twice
Two lines each need 2 of an item, and you have 3. Each line passes on its own, the craft runs, and the second one stops at zero or goes below it, so items are lost or appear from nowhere.
Fix: Tell your AI: add up the lines for each item before comparing with what the player has.
A full stock eats the result
If the ingredients are taken first and the result is then cut off at the limit, the extra result is lost.
Fix: Tell your AI: check that the result fits before anything changes, and count the room the ingredients free up.
Taking ingredients one at a time
The game takes each ingredient in turn and gives up when one is missing, so the player loses part of the ingredients and gets nothing.
Fix: Tell your AI: check everything first, then do all of it at once.
A recipe that gives back what it takes
A recipe that returns part of an ingredient looks wrong when the game checks what goes in and what comes out separately.
Fix: Tell your AI: work out the room from what the player will have after the ingredients are gone.
How to check it works
- You have everything a recipe needs. you craft it: the ingredients are gone, the results appear, and the game shows the craft worked.
- You are missing one ingredient. you try to craft the recipe: nothing changes and the game says you are short of something.
- A recipe has two lines of 2 stones, and you hold 3, then 4. you try to craft it: with 3 it is refused and nothing changes, with 4 it works and leaves none.
- The result would take you past the limit. you try to craft the recipe: nothing changes and the game says there is no room.
- You are at the limit, and a recipe takes 5 of an item and gives 2 back. you craft it: it works and you end up with 3 fewer.
- You have what a chain of three recipes needs. you craft them in order: each one uses the result of the one before.
- You are close to the limit. you ask your AI to give you more of the item: it stops at the limit, and a gain of less than one does nothing.
Works well with
- Inventory System: This page keeps a simple count per item. With slots, the room check must also look at stacks and free slots. Check the whole recipe first, then take and give in one go.
Common questions
how do you make a crafting system
Keep recipes as simple lists of what is taken and what is given. Check the whole recipe against what the player holds, then take and give in one go, so a craft never stops halfway.
how do i check if the player can craft a recipe
Add up each item across all the ingredient lines before comparing it with what the player holds. Checking each line alone lets through a recipe that lists an item twice.
what should happen if the crafted item does not fit
Refuse the craft before anything is taken, and tell the player why. Taking the ingredients first and throwing away the result loses items.
what do i tell my ai to add crafting
Paste this: Add crafting with recipes stored as data, as lists of ingredients and results, so they can be checked, tested and changed and one craft step works for every recipe. Check the whole recipe first, then take and give in one go.
Where it comes from
Earliest example we could find: Dungeons & Dragons, Volume 1: Men & Magic (Gygax and Arneson, Tactical Studies Rules) (1974). Tabletop rules let high-level magic-users make items such as potions and scrolls, for their own use or for sale, with money and game time as the inputs. It has no gathered materials or recipes, so it is item making by spending resources, not crafting in the later video game sense. The rulebook was read in an unofficial copy, which is not linked here.
- 1974 Dungeons & Dragons, Volume 1: Men & Magic (Gygax and Arneson, Tactical Studies Rules): Tabletop rules let high-level magic-users make items such as potions and scrolls, for their own use or for sale, with money and game time as the inputs. It has no gathered materials or recipes, so it is item making by spending resources, not crafting in the later video game sense. The rulebook was read in an unofficial copy, which is not linked here. [Dungeons & Dragons (1974), Wikipedia, bibliographic reference]
- 1989 Knights of Legend (Origin Systems): Single-player CRPG in which ingots found in play can be turned into forged items, by an NPC according to a reader comment on the blog. The CRPG Addict lists it as the game that opened crafting of weapons or armor, and also judges the feature unimpressive because the player decides almost nothing about the result. [First! (The CRPG Addict, 2012)][Knights of Legend: Final Rating (The CRPG Addict, 2013)][Knights of Legend, Wikipedia]
- 1992 Legends of Future Past (CompuServe online game): Text-based online game with resource harvesting (ores, herbs, skins) and item crafting. This is the earliest crafting system in an online game documented here, apart from undated DikuMUD recipes. Wikipedia and a retro magazine are the only sources found. [Legends of Future Past, Wikipedia][The Online Beginning of Gaming (Old School Gamer Magazine, 2023)]
- 1997 Ultima Online (Origin Systems): Crafting as a player trade inside a designed economy. Characters become manufacturers through skills such as smithing and tailoring, and turn gathered raw materials into goods other players buy. Raph Koster says the resource idea began in early 1995 as a way to improve MUD crafting: objects carry material labels, so crafting code can ask what something is made of instead of listing item IDs in each recipe. [UO's resource system (Raph Koster, 2006)][The In-game Economics of Ultima Online (Zachary Booth Simpson, 1999)][Ultima Online, Wikipedia]
- 1997 Atelier Marie: The Alchemist of Salburg (Gust, PlayStation): Opening game of a series in which making things is the central theme, not a side system: players collect objects and combine them through alchemy recipes. Wikipedia describes the series in general and not this game's specific rules, so the detail for this one game is thin. [Atelier (video game series), Wikipedia]
- 2009 Minecraft (Mojang): In the public alpha period players gather natural resources and craft blocks and items, and crafting is the route to almost everything else in the game. Game Developer says it brought crafting to a large new audience. The date is that of the public alpha; the formal release came in 2011. [Minecraft, Wikipedia][7 crafting systems game designers should study (Bryant Francis, Game Developer, 2015)][10 years on, 'Minecraft''s crafting system remains unmatched (Rick Lane, NME, 2022)]
What was checked
- 10 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