Containers
A container keeps what is put in it: a chest, a barrel, a wagon, a stash. A new project has none. Edit > Project Settings > ITEMS > Containers lists every container the project has, and a placed prop becomes one in its Properties.
The Containers page
One row per container.
- Container
- Its id: letters, digits, _ and -. Its file is
assets/data/containers/<id>.vfa. - Contents
- Keeps: what the player takes is gone and what the player leaves stays. Refills: back to its starting contents after the days in Days. Click to switch.
- Days
- How many game days a container that refills waits. Blank or 0 makes it keep its contents.
- Shared
- Ticked, every prop that names the id opens the same contents: a stash. Unticked, each prop keeps its own contents, all starting from the same list.
- Size
- How many stacks it holds. Blank holds up to 512.
- Used by
- How many props on the project's maps name it.
- Edit Contents
- Its starting contents, in the two lists the NPC Portfolio's Edit Inventory uses: pick an item on the left and press >>, change a count with - and +, remove a row with x. Done goes back to the table.
New container takes an id and makes its file. The bin deletes a container; when props use it, it says how many and on which maps before it asks.
Placing one
Select a prop, tick Interactable, and set Type to Container.
- Container
- Which container it opens. New... takes a new id and makes its file.
- Edit Contents
- Opens the Containers page on its starting contents.
A Container prop is given a tag when it has none. A container that is not shared remembers each prop's contents by the prop's map and tag.
In play
The player presses the use key beside it and the Take and Store window opens, drawn in the project's style pack. If the prop has an event, its [use] section runs too.
- Take
- The container's stacks. A click takes one, Shift-click takes the stack, and Take all takes everything that fits.
- Store
- The player's pockets. A click stores one, Shift-click stores the stack.
Every move goes through the same rules as everything else that enters or leaves the pockets: stack limits, the number of pockets, and weight when the project has a carry limit. When the pockets cannot hold it, nothing is taken and the window says so ("Your pockets are full."). A stack that only partly fits moves as much as fits. Key items cannot be stored. A container at its Size takes nothing more. Esc closes the window.
Want your own look? Paint a screen named container in the UI Editor and every container opens on it instead of this window. Stacks drag between its Container widget and its Pockets widget, under the same rules.
Refilling
A container that refills counts its days from the first time the player changes it. On the first opening after they have passed, it holds its starting contents again, and anything the player left in it is gone. Days pass with the world clock and with resting.
From a script
container <id> opens a container from any script. Opened this way it shows the contents every script opening that id shares; for a shared container those are the stash's contents.
A script can answer the container event:
before container(text action, text container, text item, number count) {
if (action == "take" && item == "cursed_idol") refuse("It will not come loose.")
}- action
- open, close, take or store.
- container
- The container's id.
- item, count
- The item and how many, for take and store.
A before block may refuse an open, a take or a store, or change how many a take or a store moves. Close is raised only as after. Each Take and each Store also counts once as the deed take or store, for a quest's counting stage and for story triggers.
Saves
A container the player has changed is saved as one cont <key>=<item>:<count>,... line, and one that refills also saves contday <key>=<day>. Each value is one word, so an older build skips both. A save made before containers existed, or one where the player never changed a container, opens every container at its starting contents. A container deleted from the project is dropped when a save loads.
The chest verb's once-only treasure is not a container and works as it always has.