How to create containers and add items
Containers are the universal abstraction for where items live.
Add an item to an empty container
Like in Elden Ring where players can carry anything, when you create a container with unlimited capacity, it accepts items without restriction. Adding one “iron_sword” to an empty “inventory” container results in the inventory holding exactly one item.
Add an unregistered item fails
If you try to add an item that hasn’t been registered with the system, the operation will fail. For example, attempting to add 1 “unknown_item” to an unlimited-capacity container called “inventory” produces an unregistered item error. You must register item types before they can be placed into any container.
Add multiple different items
When you create a container with unlimited capacity, it tracks each distinct item type as a single entry regardless of stack size. Adding 1 “iron_sword”, 3 “health_potion”, and 5 “golden_rune” to your inventory results in 3 items — one entry per item type, not one per unit.
Multiple containers are independent
Each container operates independently. If you create two unlimited containers — say “item_box” and “hunt_pouch” — adding an item to one has no effect on the other. The container you added to will hold that item, while the other remains empty.
Query an empty container
When you create a container with unlimited capacity and query it before adding anything, the result is empty. This is the baseline state — a freshly created container like “inventory” holds no items until you explicitly add them.
Query item quantity
When you add items of the same type to a container multiple times, their quantities stack. If you add a first batch and then a second batch of the same item to your inventory, querying the quantity of that item returns the combined total.
Query items in a container
Much like checking your inventory in Skyrim after picking up loot, you can query a container to see what’s inside. If you create an “inventory” container with unlimited capacity and add 1 “iron_sword” and 3 “health_potion” to it, querying “inventory” confirms that both “iron_sword” and “health_potion” are present, while items you never picked up — like “golden_rune” — are not.
Query quantity of an item not in the container
When you query the quantity of an item that hasn’t been added to a container, the result is 0 rather than an error. For example, asking for the quantity of “iron_sword” in an empty unlimited-capacity “inventory” container simply returns 0, making it safe to check quantities without first verifying whether an item exists.
Remove an item from a container
When you remove an item from a container, it’s no longer tracked. If you add an “iron_sword” to an unlimited-capacity “inventory” container and then remove it, the container will be empty with 0 items.
Remove an item that is not in the container
If you try to remove an item that doesn’t exist in the container — for example, removing “iron_sword” from an unlimited-capacity “inventory” that doesn’t contain it — the operation fails with a not found error rather than silently succeeding.
Generated from core/tests/features/container.feature