Inventory Generator
Item.gd · Inventory.gd · InventoryUI.gd · SlotPanel.gd
GDScript 4.x
Item Resource — Core Fields
These are the built-in fields every item has. All become @export vars in Item.gd so you can fill them in the Godot inspector per .tres file.
class name
id field name
name field name
texture field name
stack capacity field
space occupied field
default stack capacity
3D model field PackedScene (optional)
Remove Mode
When a stack is dragged out of the inventory — remove the whole stack, or just deduct one item.
remove_mode field name
enum values
Custom Item Fields
Extra @export fields added to Item.gd — e.g. category, description, damage, weight.
Inventory Settings
autoload name (in Project Settings)
slot count
slots array name
Each slot is a Dictionary: { "item": Item, "quantity": int } or null if empty.
Signals
item_added signal
item_removed signal
inventory_full signal
slot_updated signal
InventoryUI — Export Vars
These become @export vars on the InventoryUI root node. Assign them in the Godot inspector — no hardcoded paths in code.
script class name
GridContainer export var name
Slot template PackedScene export var name
Texture NodePath export var name
Quantity Label NodePath export var name
Custom UI Field Bindings
Each binding is an @export NodePath on InventoryUI. Assign the label/node in inspector. The generator wires it to the matching item field.
export var nameitem field it shows
SlotPanel — Drag & Drop
SlotPanel.gd is attached to each duplicated panel node. It handles all drag and drop logic using Godot 4's built-in system.
script class name
slot index var name
inventory UI parent var name
drag preview scene export var
Drop outside inventory area respects item's remove_mode — FULL_STACK removes all, ONE_BY_ONE deducts 1.
Item.gdsave as Resource, make .tres
# tap Generate to produce code
Inventory.gdadd as Autoload singleton
# tap Generate to produce code
InventoryUI.gdattach to inventory scene root
# tap Generate to produce code
SlotPanel.gdattach to slot template scene root
# tap Generate to produce code