nut.inventory
Inventory System.
Base framework for creating and managing different inventory implementations.
Functions
nut.inventory.newType (typeID, invTypeStruct)
nut.inventory.newType
Performs type checking for new inventory types then stores them into nut.inventory.types if there are no errors.
Parameters:
string typeID Unique identifier for the inventory typetable invTypeStruct Inventory type definition table
Raises:
Error if type validation fails or typeID existsUsage:
nut.inventory.new (typeID)
nut.inventory.new
Creates an instance of an inventory class whose type is the given type ID.
Parameters:
string typeID Type identifier to instantiateReturns:
table New inventory instanceRaises:
Error if typeID doesn't existUsage:
nut.inventory.show (inventory, parent)
nut.inventory.show
Displays an inventory UI panel (client-only)
Parameters:
table inventory Inventory to displayPanel
parent
optional
Parent panel for the UI
Returns:
panel Created inventory panelSee also:
nut.inventory.loadByID (id, noCache)
nut.inventory.loadByID
Loads an inventory by its ID
Parameters:
number id Inventory ID to loadboolean
noCache
optional. default
: false
Whether to bypass cache
Returns:
promise Promise resolving to inventory instancenut.inventory.loadFromDefaultStorage (id, noCache)
nut.inventory.loadFromDefaultStorage
Loads inventory from default storage
Parameters:
number id Inventory ID to loadboolean
noCache
optional. default
: false
Whether to bypass cache
Returns:
promise Promise resolving to inventory instancenut.inventory.instance (typeID, initialData)
nut.inventory.instance
Creates a new inventory instance
Parameters:
string typeID Inventory type identifiertable
initialData
optional
Initial inventory data
Returns:
promise Promise resolving to new inventory instancenut.inventory.loadAllFromCharID (charID)
nut.inventory.loadAllFromCharID
Loads all inventories for a character
Parameters:
integer charID Character ID to load forReturns:
promise Promise resolving to table of inventoriesnut.inventory.deleteByID (id)
nut.inventory.deleteByID
Deletes an inventory by ID
Parameters:
integer id Inventory ID to deletenut.inventory.cleanUpForCharacter (character)
nut.inventory.cleanUpForCharacter
Cleans up inventories for a character
Parameters:
table character Character to clean up forTables
InventoryTypeDef
InventoryTypeDef
Inventory Type Definition Structure
Fields:
vararg __index Metatable reference (must be "table")function add Function to add items (server-only, required)
function remove Function to remove items (server-only, required)
function sync Function to sync inventory (server-only, required)
string typeID Unique string identifier (required)
string className Class name for metatable (required)
table config Configuration table (optional)
InventoryInstance
InventoryInstance
Inventory Instance Structure
Fields:
vararg config Type-specific configurationinteger id Unique numeric identifier
table items Table containing inventory items