Inventory
Overview
All Out provides a player inventory API that allows you to create items, give them to players, and for players to arrange, use, and drop items in your game.
There are three core concepts:
Item definitions (
Item_Definition): what an item is (name/icon/stacking + your own fields)Item instances (
Item_Instance): an actual stack in the world/in an inventoryInventories (
Inventory): a container of slots that holds item instances
Every player has a built-in inventory at player.default_inventory.
Persistence
If you'd like player inventories to be automatically saved across game sessions, enable the Auto Save Player Inventory box in the Edit → Game Config section of the editor.

Named player inventories
Create persistent inventories only during the player's ao_start. Each key belongs to that player:
The call returns a restored inventory synchronously. Repeating it with the same player and key during ao_start returns the same inventory without resetting its contents or capacity. Calls outside that player's ao_start fail even if the inventory already exists; keep the returned inventory in a field for later use. Keys must contain only letters, numbers, underscores, or hyphens and cannot be empty. Keep the key stable across game versions.
Named inventories are automatically saved independently of the default inventory's auto-save setting. The engine saves and destroys them when the player leaves; do not add a matching destroy_inventory call. Removing a registration from your game does not erase its saved data. Use the existing item movement and inventory drawing APIs with the returned inventory.
The default inventory keeps its existing $AO.inventory save key, encoded format, and fetch path. Named inventories use separate $AO.inventory_<key> save entries. Both travel through the existing player startup path; no default-inventory migration is needed.
For a saved inventory, capacity is the greater of the requested initial capacity and saved capacity. Use Items.set_capacity for subsequent changes. Register item definitions before players join.
After directly modifying an item's @ao_serialize fields, call Items.mark_item_dirty(item) to save the containing inventory. Normal inventory operations already mark changes dirty. CSL networking replicates the fields automatically.
Inventory API reference
Quick start (register + give an item)
Register item definitions once in ao_before_scene_load, then create instances and move them into a player’s inventory.
Every custom Item_Instance field that must survive inventory save and restore needs @ao_serialize. A field without it returns to its normal default after restoration. For nested custom classes, annotate both the containing field and each nested field that must persist.
Persist a selection such as an equipped weapon using Save.save_item_reference(player, key, item) and Save.get_item_reference(player, key). The item may belong to the player's auto-saved default_inventory or any named player inventory. References survive slot rearrangement within that inventory and rejoining. Removing, dropping, destroying, or transferring an item to any other inventory invalidates its old references, even for the same player or if the item later returns. A stack consumed by a merge also invalidates its references. Create named inventories before resolving saved selections. Inventory remains authoritative for ownership and item fields, so do not copy those values into Save.
item.entry_id_in_inventory exposes the current inventory's entry number for diagnostics. It is positive while the item is owned, remains unchanged when slots are rearranged, changes on transfers, and becomes 0 when detached. Save references include the inventory key along with this number. Use Save.save_item_reference rather than persisting the number directly.
Displaying the hotbar
To show the standard inventory hotbar UI on screen, call Items.draw_hotbar inside your Player's ao_late_update method. Without it, the inventory system works behind the scenes but the player won't see it!
Checking if a player already has an item
A common pattern is to give an item only if the player doesn't already have one:
Use the definition's registered ID:
You can also check how much room is left for a specific item type before creating it:
Custom Inventories
You can create inventories that aren’t tied to a player, for things like:
Chests / storage containers
Fish/mob teams
To access items:
slots() visits every slot in order. item is null for an empty slot, and the optional second loop variable is the actual slot index. Use get_item(index) when you need random access to one slot.
Atomic item moves
Use a transaction when several item moves must either all succeed or all fail:
Each item instance may appear only once in the transaction. Always call can_move_all_items first; move_all_items asserts if the complete transaction no longer fits. A move can merge a stack and destroy the moved instance, so do not keep using item references after the transaction.
Dropped Items
If you want players to drop items into the world (and let other players pick them up), use the dropped items system:
Spawning a dropped item
Drop animation + snapping to navmesh
Handling drag-drop from the hotbar UI
If you use Items.draw_hotbar, players can drag an item out of the UI to drop it. Dropped_Item.handle_dropped_item removes it from the inventory and spawns a dropped item entity.
Last updated