Working with containers

Containers are a way of storing inventory items outside of the Player's inventory - for example, the contents of a chest, or the inventory of an NPC.

Containers can be added from the Logic panel in the Scene Manager's list of prefabs:

Inside a Container's Inspector, define the items you wish to be placed inside it by default. If an item has Can carry multiple? checked, you can also set how many of that item is added:

To view a Container's items, a Menu with an InventoryBox element that has an Inventory box type property set to Container is required. AC's default interface includes one in the form of the Container menu, which displays both a Container's items as well as the Player's current inventory:

To view a Container's items with this menu, use the Container: Open Action:

When this Action is run, the ActionList will end and the Container will take over gameplay. The player can click either on their own inventory, or items in the Container, to transfer them to one another. Transferring can occur in a number of ways, as defined by the Click behaviour property of the Container menu's ContainerItems element:

Container items can also be displayed in different Menus by checking Open in set element in the Container: Open Action. Doing so will not automatically open that menu, however, so an additional Menu: Change state Action is required:

Container items can also be modified using the Container: Add or remove Action, and its contents queried with the Container: Check: Action.

To have a Container's items be recorded in save-game files, a Remember Container component is required. This is added automatically when creating Containers using the Scene Manager.

A Container normally exists in a single scene. However, it can be made to survive scene changes - and exist in all scenes - using this script on the AC wiki.

Containers are also used to display a shopkeeper's items in the Shop system package on AC's Downloads page.