Storage
Scripting with the Storage class.
Fields & Properties
id
The storage ID.
string
public
navigation
The navigation type.
Vault.Navigation
public
isInfinite
If the storage is infinite.
bool
public
currentPage
The current page number.
int
public
maxPages
The max number of pages. This is only relevant if the navigation type is set to pagination and the storage is not infinite.
int
public
minPageSize
The minimum size of the page. This is only relevant if navigation is set to scrolling and the storage is infinite.
Vector2Int
public
pageSize
The size of each page. This is only relevant if navigation is not set to scrolling and the inventory/storage is not infinite.
Vector2Int
public
itemStacks
A list of all items stacks in the storage.
List<ItemStack>
public
currencies
A list of stored currencies.
List<Currency>
public
itemSlots
A list of all item slots.
ItemSlot[]
public
orderMode
The order mode of the items.
Vault.OrderMode
public
activeItemTypeFilter
The active item type filter.
ItemType
public
PageSlotCount
The number of total slots per page.
int
public
TotalSlotCount
The number of total slots, combining all slots in all pages.
int
public
AllowItemDropping
If item dropping should be allowed. Taken from the inventory.
bool
public
ShowSubtypes
If item subtypes should be displayed in the storage filter list. Taken from the inventory.
bool
public
DeleteItemsOnDrop
If the item should be deleted on drop. Taken from the inventory.
bool
public
NoFilterIcon
The icon of the no filter button. Taken from the inventory.
Sprite
public
NoFilterIconColorTint
The color tint of the no filter icon. Taken from the inventory.
Color
public
Items
Setting Items
You can set items with the SetItems
method. This will remove all previous items in the inventory.
Depositing Items
With the Deposit
method, you can add a single or a list of item stacks to the storage. This will remove the item(s) from the inventory.
Remove Items
With the Withdraw
method, you can remove a single or a list of item stacks from the storage. This will add the item(s) to the inventory.
Getting Items
You can get the full list of items with the itemStacks
and keyItems
fields.
Get All Items in a Specific Page
Get All Items in the Current Page
Checking If An Item Can Fit
You can check if an item will fit in the storage with the HasSpaceForItem
method.
Checking Items
You can use the Contains
method to check and see if the player has an instance of an item in their storage. You can use an Item
object, the item ID, or the item name to perform this check.
Drop Items
To drop a specific item (remove it from the storage), use the DropItem
method. This may create an instance of an Item Drop in the game world.
Currencies
In the examples below, amount
is a Currency. You can access the full list of currencies with the myStorage.currencies
field.
Depositing a Currency
A currency can be deposited with the Deposit
method.
Withdrawing a Currency
A currency can be withdrawn from the storage with the Withdraw
method.
Resetting
You can reset all currencies to their starting values with the ResetCurrencies
method.
Pages & Organization
Storage items are organized in grid-based pages. Whether your inventory 1 page or 100, the logic is the same.
Reorganization
You can reorganize the storage with the Reorganize
method.
If you'd only like to regroup item stacks, use the Regroup
method.
Filters
Storage items can be filtered with Item Type. Items that don't match the filter will not be returned when using the GetAllItemsInPage
or GetAllItemsInCurrentPage
methods. If the ItemType
is a parent, items with the parent type or any of it's child types will not be filtered out.
Set the Item Filter
Remove Item Filter
Page Sizes
Setting the Size
You can set the page size by editing the minPageSize
or pageSize
fields. When these are changed, the storage may need to be reorganized.
Recalculating the Size
Page sizes may need to be recalculated when the storage is infinite, navigation is set to scrolling, and new items are added. Call the RecalculatePageSize
method for this purpose. This will update the pageSize
field automatically.
Pagination
Current Page
The current page number is stored in the currentPage
field.
You can flip to the next page with the NextPage
method.
Similarly, you can flip to the previous page with PreviousPage
method.
Alternatively, you can set the current page (page numbers start at 0).
Recalculate Required Pages
The maxPages
field is an integer that stores the max number of pages that the storage has. The pages can be limited or unlimited (this can be set from the Storage). In the case they are unlimited, the maxPages
field may need to be recalculated at times. You can call RecalculateRequiredPages
for this purpose.
Minimum Required Pages
You can get the minimum required pages to fit all items with the MinimumRequiredPages
method.
Last updated