Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How to use slot constraints

Containers with SlotCount constraint limit the number of distinct item stacks.

Add items exceeding slot limit

When your container has a hard SlotCount(2) constraint, it can hold at most two distinct item stacks. If you add a “weapon” to the “loadout” container twice, filling both slots, any further attempt to add another “weapon” will fail with a capacity exceeded error. Each addition occupies one slot, and the hard constraint strictly prevents exceeding the limit.

Add items within slot limit

When your container has a hard SlotCount constraint, it limits how many distinct item stacks the container can hold. If you create a container called “loadout” with a SlotCount of 3, adding a single weapon succeeds without issue — the container now holds 1 item, well within its 3-slot limit.

Remove item frees a slot

When you remove an item from a slot-limited container, that slot becomes available again. If your “loadout” container has a hard SlotCount(2) constraint and you add two “weapon” items, removing one frees up a slot. You can then add another “weapon” successfully, leaving the container with 2 items total. Slot capacity tracks current occupancy, not historical usage.

Swap item in full container

When a container is full, you can still swap items by removing one first. If your “loadout” container has a hard SlotCount(2) constraint and already holds a “weapon” and a “shield,” removing the “weapon” frees a slot, letting you add a new “weapon” back in. The container ends up with 2 items, never exceeding its slot limit at any point during the swap.


Generated from core/tests/features/slot_capacity.feature