Storage
Scripting with the Storage class.
Fields & Properties
navigation
The navigation type.
Navigation
public
isInfinite
If the vault is infinite.
bool
public
pages
A list of grid pages.
List<Grid>
private
currentPage
The current page number.
int
public
pageSize
The size of each page. This is only relevant if navigation is not set to scrolling and the vault is not infinite.
Vector2Int
public
minPageSize
The minimum size of the page. This is only relevant if navigation is set to scrolling and the vault is infinite.
Vector2Int
public
pageSizeRuntime
The number of pages calculated at runtime.
Vector2Int
public
maxPages
The max number of pages. This is only relevant if the navigation type is set to pagination and the vault is not infinite.
int
public
itemStacks
A list of all items stacks in the vault. For storage, use the Deposit and Withdraw methods to change the list instead of editing the list itself.
List<ItemStack>
public
filteredItemStacks
The item stacks with the active item type filter applied.
List<ItemStack>
public
currencies
A list of stored currencies.
List<Currency>
public
activeItemTypeFilter
The active item type filter.
ItemType
public
canAcceptItem
A function that can be used to limit the items that the storage can accept.
Func<ItemStack, bool>
public
PageCount
The number of pages calculated at runtime.
int
public
PageSlotCount
The total number of slots on a single page.
int
public
SlotCount
The total number of slots.
int
public
id
The storage ID.
string
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. This will also recreate all pages.
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.
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).
Customize Accepted Items
You can customize the items accepted with the canAcceptItem
function.
Example
Last updated