class Inventory: Component, IQueryable

A configurable inventory.

totalCount: integer

The current item/stack count in the inventory.

totalWeight: number

The current weight in the inventory.

totalVolume: number

The current volume in the inventory.

limitCount: integer

The number of total items/stacks allowed in the inventory.

limitWeight: number

The total weight allowed in the inventory.

limitVolume: number

The total volume allowed in the inventory.

multipleStacks: boolean
__new(self: Inventory, options: any)

Constructor for inventory, see the InventoryOptions for more on the options available.

inventory: ActorStorage

ActorStorage is a container class used to manage a collection of Actor objects. It maintains internal structures for efficient lookup, spatial queries, and component caching.

This class is primarily used internally by the Level class, and most users will interact with it through Level methods. However, it can also be used in other specialized contexts such as inventory systems or sensory subsystems (e.g., tracking visible actors).

hasItem(self: Inventory, actor: Actor): boolean

Checks if the inventory is already holding this actor.

getStack(self: Inventory, stackable: fun(...any): Actor): (stack?: Actor)

Gets any current actor that can stack with the stackable type specified. If multipleStacks is false it will return full stacks.

canAddItem(self: Inventory, actor: Actor): (success: boolean, err?: string)

Checks if we can add the actor to the inventory.

addItem(self: Inventory, actor: Actor)

Adds the actor to the inventory, stacking it if possible.

removeItem(self: Inventory, actor: Actor): Actor

Removes an actor from the inventory, returning it.

canRemoveQuantity(self: Inventory, actor: Actor, count: integer): boolean

Checks if we can remove a specific quantity from the actor in the inventory’s stack.

removeQuantity(self: Inventory, actor: Actor, count: integer): Actor

Removes a quantity of an item from the actor. This creates a new actor using the stackable factory and correctly sets its stack count using item:split().

updateLimits(self: Inventory)

Updates the count, volume, weight of the inventory.