Submodule representing the player's inventory (equipment, bag, and pockets). Accessible through mod.game.inventory
.
You need to specifically request this submodule during your module's initialization by calling mod.game.initialize
!
- Checks whether the given item is in the equipment.
- Checks whether the given item is in the bag.
- Checks whether the given item is in the given pocket.
- Checks whether the given item is in any pocket.
- Checks whether the given item is in the bag or any pocket.
- Returns the total amount of items with the given ID (or array of IDs) in both equipment and bag combined.
- Exemplary usage:
mod.game.inventory.getTotalAmount(CONSUMABLE_ID)
- Returns the total amount of equipped items with the given ID (or array of IDs).
- Exemplary usage:
mod.game.inventory.getTotalAmountInEquipment(CONSUMABLE_ID)
- Returns the total amount of bag items with the given ID (or array of IDs).
- Exemplary usage:
mod.game.inventory.getTotalAmountInBag(CONSUMABLE_ID)
- Returns the total amount of items with the given ID (or array of IDs) in the given pocket.
- Exemplary usage:
mod.game.inventory.getTotalAmountInPocket(1, CONSUMABLE_ID)
- Returns the total amount of items with the given ID (or array of IDs) in all pockets combined.
- Exemplary usage:
mod.game.inventory.getTotalAmountInPockets(CONSUMABLE_ID)
- Returns the total amount of items with the given ID (or array of IDs) in the bag and all pockets combined.
- Exemplary usage:
mod.game.inventory.getTotalAmountInBagOrPockets(CONSUMABLE_ID)
- Returns the first item with the given ID (or array of IDs) found in both equipment and bag combined.
- Exemplary usage:
mod.game.inventory.find(CONSUMABLE_ID)
- Returns the first equipped item found with the given ID (or array of IDs).
- Exemplary usage:
mod.game.inventory.findInEquipment(CONSUMABLE_ID)
- Returns the first bag item found with the given ID (or array of IDs).
- Exemplary usage:
mod.game.inventory.findInBag(CONSUMABLE_ID)
- Returns the first item found with the given ID (or array of IDs) in the given pocket.
- Exemplary usage:
mod.game.inventory.findInPocket(1, CONSUMABLE_ID)
- Returns the first item found with the given ID (or array of IDs) in any pocket.
- Exemplary usage:
mod.game.inventory.findInPockets(CONSUMABLE_ID)
- Returns the first item found with the given ID (or array of IDs) in the bag or any pocket.
- Exemplary usage:
mod.game.inventory.findInBagOrPockets(CONSUMABLE_ID)
- Returns all items with the given ID (or array of IDs) in both equipment and bag combined.
- Exemplary usage:
mod.game.inventory.findAll(CONSUMABLE_ID).forEach(item => ...)
- Returns all equipped items with the given ID (or array of IDs).
- Exemplary usage:
mod.game.inventory.findAllInEquipment(CONSUMABLE_ID).forEach(item => ...)
- Returns all bag items with the given ID (or array of IDs).
- Exemplary usage:
mod.game.inventory.findAllInBag(CONSUMABLE_ID).forEach(item => ...)
- Returns all items with the given ID (or array of IDs) in the given pocket.
- Exemplary usage:
mod.game.inventory.findAllInPocket(1, CONSUMABLE_ID).forEach(item => ...)
- Returns all items with the given ID (or array of IDs) in all pockets combined.
- Exemplary usage:
mod.game.inventory.findAllInPockets(CONSUMABLE_ID).forEach(item => ...)
- Returns all items with the given ID (or array of IDs) in the bag and all pockets combined.
- Exemplary usage:
mod.game.inventory.findAllInBagOrPockets(CONSUMABLE_ID).forEach(item => ...)
Each of the following attributes can be accessed through, for example, mod.game.inventory.money
.
dbids
: DatabaseID -> Item object containing all items (equipment, bag, pockets)items
: array containing all items in equipment, the bag, and all pockets combinedpocketCount
: total number of unlocked pockets + 1 (as the bag is regarded to as pocket 0)pockets
: array (index 0 = bag; index 1 = first pocket; etc.) of objects withsize
(number of slots),lootPriority
(seeS_ITEMLIST
definition) andslots
(slot number -> item object; contains only used slots)equipment
: object withsize
(number of slots) andslots
(slot number -> item object; contains only used slots)equipmentItems
: array containing all equipped itemsbag
: redirects topockets[0]
bagItems
: array containing all items in bagpocketItems
: array (index 0 = bag; index 1 = first pocket; etc.) of arrays containing all items in each pocketbagOrPocketItems
: array containing all items in the bag and all pockets combinedequipmentItemLevel
: Currently equipped item leveltotalItemLevel
: Maximum possible item level across all items in equipment, the bag, and all pocketsmoney
: Total moneytcat
: Total TCatequipmentPassivities
: array containing all passivity IDs of the currently active dynamic passivities of all equipped items (e.g. weapon rolls or infused passives). Duplicates possible.equipmentCrystals
: array containing all item IDs of the crystals in all equipped items. Duplicates possible.weaponEquipped
: Indicates whether or not a weapon is equipped
Item objects returned by functions such as findInBag
, or contained in arrays/objects such as items
and dbids
, have the following attributes:
- All attributes of the
items
array in the latest version ofS_ITEMLIST
(see tera-data) container
: ID of the containerpocket
: ID of the pocket within the containerdata
: Link to the corresponding game data queried from the DataCenter file
- Emitted whenever a full batch of update packets has been received, stitched together, and parsed.
- Exemplary usage:
mod.game.inventory.on('update', () => { ... })
- Parameters: none
// Log info about all items in equipment and bag
mod.log('--- Equipment ---')
mod.game.inventory.equipmentItems.forEach(item => {
mod.log(`Slot ${item.slot}: ${item.data.name} x${item.amount} (ID: ${item.id})`);
});
mod.log('--- Bag ---')
mod.game.inventory.bagItems.forEach(item => {
mod.log(`Slot ${item.slot}: ${item.data.name} x${item.amount} (ID: ${item.id})`);
});