Inventory¶
Overview¶
The Inventory table provides access to Inv objects.
Functions¶
Find(InvType)¶
Returns the Inv associated with the supplied InvType.
| Parameter | Type | Description |
|---|---|---|
| config | InvType | A valid InvType. |
| Returns | Description |
|---|---|
| Inv | The inventory container for a list of objects. |
Find(Integer)¶
Returns the Inv associated with the matching ID.
| Parameter | Type | Description |
|---|---|---|
| id | Integer | A valid ID value. |
| Returns | Description |
|---|---|
| Inv | The inventory container for a list of objects. |
Example
Inv¶
Overview¶
An inventory provides access to a list of InvSlot entries, each of which contains information about the ObjType contained within it.
Inventories are of a fixed size, and their slots may or may not be populated by an InvSlot.
Info
An Inv object is a Proxy usertype, which means it is safe to copy and store in your scripts.
It cannot, however, be used with any persistent storage.
Warning
Use Inv.isValid to confirm that an inventory still exists before trying to access its properties.
Inventories can be added or removed from the client by the server for a variety of reasons e.g. the player closes a shop interface.
When an inventory's data is removed it will become invalid, and any copies of this usertype should be disposed of.
If the same inventory data is re-added to the client by the server, such as walking back into visibility range, then a different new Inv object will be created.
Methods¶
GetSlot¶
Returns the InvSlot at the specified index.
Warning
This function returns a copy of the data in the specified slot at the time of execution.
| Parameter | Type | Description |
|---|---|---|
| index | Integer | A valid slot index.Index values are 1-indexed. |
| Returns | Description |
|---|---|
| InvSlot | An object representing the inventory slot specified. Returns nil on failure. |
Example
GetSlots¶
Returns the current data associated for all slots in the inventory.
Warning
This function returns a copy of the data in the specified slot at the time of execution.
| Returns | Description |
|---|---|
| [InvSlot] | An table of objects representing the inventory slot specified. Returns nil on failure. |
Example
GetTotal(ObjType)¶
Returns the number of objects matching a valid ObjType specified in the associated inventory.
| Parameter | Type | Description |
|---|---|---|
| objType | ObjType | A valid ObjType. |
| Returns | Description |
|---|---|
| Integer | The number of objects matching the specified ObjType. |
Example
GetTotal(Integer)¶
Returns the number of objects matching a valid ObjType ID specified in the associated inventory.
| Parameter | Type | Description |
|---|---|---|
| id | Integer | A valid ObjType ID. |
| Returns | Description |
|---|---|
| Integer | The number of objects matching the id. |
Example
GetCategoryTotal¶
Returns the number of objects in the inventory that are in the category specified.
| Parameter | Type | Description |
|---|---|---|
| category | Integer | A valid category of object. |
| Returns | Description |
|---|---|
| Integer | The number of objects matching the specified category. |
Example
Properties¶
| Name | Type | Description |
|---|---|---|
| id | Integer | Unique ID associated with the inventory. |
| config | InvType | InvType config used to construct the inventory. |
| valid | Boolean | Is the inventory object valid. |
| slotCount | Integer | Total number of slots. |
| usedSlotCount | Integer | Number of non-empty slots. |
| freeSlotCount | Integer | Number of empty slots. |
InvSlot¶
Overview¶
A representation of an individual inventory slot.
Properties¶
| Name | Type | Description |
|---|---|---|
| obj | ObjType | Unique ID associated with the inventory. |
| count | Integer | Number of objects in the slot. |