lia.inventory

Inventory manipulation and helper functions.

Functions

cleanUpForCharacter(character)

Cleans up all inventory instances associated with a character.

Parameters

  • character Character

    The character for which to clean up inventory instances.

deleteByID(id)

Deletes an inventory instance by its ID from the database and cache.

Parameters

  • id number

    The ID of the inventory to delete.

instance(typeID, initialData)

Creates and initializes a new inventory instance based on the specified type ID and initial data.

Parameters

  • typeID string

    The ID of the inventory type.

  • initialData table optional

    Initial data to be assigned to the inventory.

Returns

  • Deferred

    A deferred object that resolves with the created inventory instance.

loadAllFromCharID(charID)

Loads all inventory instances associated with a character ID.

Parameters

  • charID number

    The character ID to load inventory instances for.

Returns

  • Deferred

    A deferred object that resolves with an array of loaded inventory instances.

loadByID(id, noCache)

Loads an inventory instance by its ID from cache or default storage if not cached. If the inventory is found in the cache and noCache is not set, it will return the cached instance. If the inventory is not found in the cache or noCache is set, it attempts to load it from storage. If the inventory is not found in storage, it falls back to the default storage.

Parameters

  • id number

    The ID of the inventory to load.

  • noCache bool default: false

    If true, forces loading from storage even if cached.

Returns

  • Deferred

    A deferred object that resolves with the loaded inventory instance or nil if not found.

loadFromDefaultStorage(id, noCache)

Loads an inventory instance from the default storage.

Parameters

  • id number

    The ID of the inventory to load.

  • noCache bool default: false

    If true, forces loading from storage even if cached.

Returns

  • Deferred

    A deferred object that resolves with the loaded inventory instance or nil if not found.

new(typeID)

Creates a new inventory instance of the specified type.

Parameters

  • typeID string

    The unique identifier for the type of inventory to create.

Returns

  • Inventory

    A new instance of the specified inventory type.

newType(typeID, invTypeStruct)

Creates a new inventory type.

Parameters

  • typeID string

    The unique identifier for the new inventory type.

  • invTypeStruct table

    The structure defining the behavior and configuration of the new inventory type.

show(inventory, parent)

Displays the graphical representation of an inventory.

Parameters

  • inventory Inventory

    The inventory to display.

  • parent Panel

    The parent panel to attach the inventory to.

Returns

  • Panel

    The panel displaying the inventory.