inventory-system
Skill870 starsChanged 21 days agoMITView on GitHub
Use when building inventory systems — Resource-based items, slot management, stacking, and UI binding
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Whaocaii/ai-game-skillstheir own version, first seen Oct 17, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- Whaocaii/ai-game-skills★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository62 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- authoring-godot-prompter-skillsSkill
- releasing-godot-prompterSkill
- 2d-essentialsSkill
- 3d-essentialsSkill
- ability-systemSkill
- addon-developmentSkill
- ai-navigationSkill
- animation-systemSkill
- assets-pipelineSkill
- audio-systemSkill
- beehaveSkill
- camera-systemSkill
- component-systemSkill
- csharp-godotSkill
- csharp-signalsSkill
- dedicated-serverSkill
- dependency-injectionSkill
- dialogue-managerSkill
- dialogue-systemSkill
- event-busSkill
- export-pipelineSkill
- gdextensionSkill
- gdscript-advancedSkill
- gdscript-patternsSkill
- godot-brainstormingSkill
- godot-code-reviewSkill
- godot-debuggingSkill
- godot-grillSkill
- godot-mentorSkill
- godot-optimizationSkill
- godot-project-setupSkill
- godot-testingSkill
- godot-uiSkill
- hud-systemSkill
- input-handlingSkill
- limboaiSkill
- localizationSkill
- math-essentialsSkill
- mobile-developmentSkill
- multiplayer-basicsSkill
- multiplayer-syncSkill
- multithreadingSkill
- particles-vfxSkill
- phantom-cameraSkill
- physics-systemSkill
- player-controllerSkill
- popochiuSkill
- procedural-generationSkill
- rendering-pipelineSkill
- resource-patternSkill
- responsive-uiSkill
- save-loadSkill
- scene-organizationSkill
- shader-basicsSkill
- state-machineSkill
- tween-animationSkill
- using-godot-prompterSkill
- web-exportSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
All examples target Godot 4.3+ with no deprecated APIs.
- Distinctive: line 64
If your game needs something else — a weight-based bag with no slots, a grid inventory with shaped items, an infinite stack list — say so …
- Very specific: line 93
Add equipment slots (HEAD, CHEST, WEAPON, etc.) with an Equipment node beside the Inventory, holding a slot map keyed by a SlotType enum.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Inventory Systems in Godot 4.3+
All examples target Godot 4.3+ with no deprecated APIs. This skill carries the decisions; the implementations live in references/ (GDScript first, then C#) — load the one you need.
Related skills: resource-pattern for custom Resource data containers, save-load for inventory serialization, event-bus for inventory change notifications, hud-system for inventory UI display, popochiu for adventure-game inventory.
1. Architecture Overview
┌─────────────────────────────────────────────────────────┐
│ UI Layer │
│ InventoryUI (Control) │
│ └─ GridContainer │
│ └─ SlotUI × N (Button) │
│ └─ TextureRect (icon) + Label (qty) │
│ │
│ Connects to: inventory_changed signal │
│ Drag-and-drop via _get_drag_data / _drop_data │
└───────────────────────┬─────────────────────────────────┘
│ reads / mutates
┌───────────────────────▼─────────────────────────────────┐
│ Inventory (Node) │
│ slots: Array[InventorySlot] │
│ add_item(item, qty) → leftover: int │
│ remove_item(item, qty) │
│ has_item(item, qty) → bool │
│ get_item_count(item) → int │
│ │
│ signals: inventory_changed │
│ item_added(item, quantity) │
│ item_removed(item, quantity) │
└───────────────────────┬─────────────────────────────────┘
│ references
┌───────────────────────▼─────────────────────────────────┐
│ Data Layer (Resources) │
│ ItemData (Resource) │
│ id, name, description, icon, max_stack_size, │
│ item_type enum │
│ │
│ InventorySlot (inner class / Resource) │
│ item: ItemData, quantity: int │
└─────────────────────────────────────────────────────────┘2. The Decisions That Matter
Three choices shape every inventory. Make them explicitly and state which you picked — the rest is mechanical.
| Decision | Take | Why |
Item identity: Resource vs. Dictionary / JSON | Resource in .tres | @export slots accept typed items, the Inspector edits them, and shared instances compare by reference |
Slot container: Resource vs. RefCounted | RefCounted | Slots are runtime state, not authored assets. A Resource invites saving slots to disk and reloading stale item copies |
add_item return: bool vs. leftover count | leftover int | Partial adds are the common case (stack caps, full bag). A bool forces the caller to re-query what actually fit |
If your game needs something else — a weight-based bag with no slots, a grid inventory with shaped items, an infinite stack list — say so before building. The fixed slot array this skill describes is the wrong skeleton for all three.
Non-obvious specifics
- Fill existing stacks before empty slots — two passes, in that order. A single naive pass scatters one item type across several slots and reports the bag full while space remains.
- Emit
inventory_changedonce per operation, after both passes complete — not once per slot touched. Per-slot emission re-renders the whole UI N times for oneadd_item. - Items compare by reference. Godot caches loaded resources, so
load()on the same.tresreturns the same instance andslot.item == itemis correct and cheap. If youduplicate()items at runtime, that breaks — key offItemData.idinstead. - Clear
itemtonullwhen quantity reaches 0, oris_empty()lies and the slot is never reusable. - Prevent stacking with data, not branches — set
max_stack_size = 1onEQUIPMENTandKEY_ITEMitems rather than special-casing them inadd_item. - C#: mark
ItemData[GlobalClass]or the Inspector will not offer it as a type when creating.tresfiles.
Inventory API contract
| Member | Returns | Contract |
add_item(item, quantity) | int | Leftover that did not fit; 0 means everything was added |
remove_item(item, quantity) | — | Removes up to quantity; silent when fewer are held |
has_item(item, quantity) | bool | Convenience over get_item_count |
get_item_count(item) | int | Summed across every slot |
inventory_changed | signal | Fired once per mutating operation — drives all UI |
item_added(item, quantity) | signal | Carries the amount actually added |
item_removed(item, quantity) | signal | Carries the amount actually removed |
Full
ItemData,Inventory, andInventorySlotimplementations in GDScript and C#: references/core-classes.md
3. Equipment Extension
Add equipment slots (HEAD, CHEST, WEAPON, etc.) with an Equipment node beside the Inventory, holding a slot map keyed by a SlotType enum. Stat aggregation sums a stats Dictionary (a property you add to ItemData) across equipped items; signal equipment_changed when slots change.
See references/equipment.md for the full GDScript and C#
Equipmentclass withSlotTypeenum, equip / unequip API, and stat aggregation.
4. UI Binding
Slot-grid UI: a GridContainer of Button slot widgets, each rendering one InventorySlot. Drag-and-drop uses _get_drag_data / _drop_data / _can_drop_data on the slot widget. The Inventory emits inventory_changed; the UI re-renders affected slots.
See references/ui-binding.md for the full GDScript and C# slot widget (drag/drop, hover preview), inventory grid layout, and tooltip wiring.
5. Serialization
Persist each slot as an {id, qty} pair (null for an empty slot), never the ItemData itself or its path. An ItemRegistry autoload loads res://items/ at startup and resolves ids back to items on load.
See references/serialization.md for the GDScript and C#
ItemRegistrywithserialize_inventory/deserialize_inventory; put the result in your save file (see save-load for itsversionfield).
Implementation Checklist
ItemDataextendsResourcewith a stableidstring set in the InspectorItemDatafiles live underres://items/and are committed to version controlInventory.add_item()returns leftover count; callers handle a full inventoryinventory_changedsignal drives all UI updates — UI never polls per-frameInventorySlot.remove_from_stack()clearsitemtonullwhen quantity reaches 0- Equipment slots keyed by
SlotTypeenum, not by string, to catch typos at compile time Equipment.get_total_stat()is called when stats are needed, not cached unless profiling demands it- Serialization stores
id + quantityonly — never fullItemDataobjects or resource paths ItemRegistryloads items at startup; all deserialization goes through it- Drag-and-drop swaps slot contents directly then emits
inventory_changedonce max_stack_size = 1onEQUIPMENTandKEY_ITEMtypes to prevent stacking- All
push_error()messages include the class name and method for easy tracing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

