API
Functions and classes available in the Lua API
Public Types | Public Member Functions | List of all members
cInventory Class Reference

#include <0014.h>

Public Types

enum  {
  invArmorCount = 4, invInventoryCount = 9 * 3, invHotbarCount = 9, invArmorOffset = 0,
  invInventoryOffset = invArmorOffset + invArmorCount, invHotbarOffset = invInventoryOffset + invInventoryCount, invNumSlots = invHotbarOffset + invHotbarCount
}

Public Member Functions

int AddItem (const cItem &a_ItemStack, bool a_AllowNewStacks=true)
int AddItems (cItems &a_ItemStackList, bool a_AllowNewStacks)
void Clear (void)
 Removes all items from the entire inventory.
void CopyToItems (cItems &a_Items)
 Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents.
bool DamageEquippedItem (short a_Amount=1)
 Adds the specified damage to the currently held item; deletes the item and returns true if the item broke.
bool DamageItem (int a_SlotNum, short a_Amount)
 Adds the specified damage to the specified item; deletes the item and returns true if the item broke.
cItemGridGetArmorGrid (void)
 Returns the cItemGrid object representing the armor slots.
const cItemGetArmorSlot (int a_ArmorSlotNum) const
const cItemGetEquippedBoots (void) const
const cItemGetEquippedChestplate (void) const
const cItemGetEquippedHelmet (void) const
const cItemGetEquippedItem (void) const
const cItemGetEquippedLeggings (void) const
int GetEquippedSlotNum (void)
cItemGridGetHotbarGrid (void)
 Returns the cItemGrid object representing the hotbar slots.
const cItemGetHotbarSlot (int a_HotBarSlotNum) const
cItemGridGetInventoryGrid (void)
 Returns the cItemGrid object representing the main inventory slots.
const cItemGetInventorySlot (int a_InventorySlotNum) const
cPlayerGetOwner (void)
 Returns the player associated with this inventory.
const cItemGetSlot (int a_SlotNum) const
bool HasItems (const cItem &a_ItemStack)
 Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack.
int HowManyCanFit (const cItem &a_ItemStack, bool a_ConsiderEmptySlots)
 Returns number of items out of a_ItemStack that can fit in the storage.
int HowManyCanFit (const cItem &a_ItemStack, int a_BeginSlotNum, int a_EndSlotNum, bool a_ConsiderEmptySlots)
 Returns how many items of the specified type would fit into the slot range specified.
int HowManyItems (const cItem &a_Item)
 Returns the number of items of type a_Item that are stored.
bool RemoveOneEquippedItem (void)
 Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed.
void SetArmorSlot (int a_ArmorSlotNum, const cItem &a_Item)
void SetEquippedSlotNum (int a_SlotNum)
void SetHotbarSlot (int a_HotBarSlotNum, const cItem &a_Item)
void SetInventorySlot (int a_InventorySlotNum, const cItem &a_Item)
void SetSlot (int a_SlotNum, const cItem &a_Item)

Detailed Description

This class represents the player's inventory

The slots are divided into three areas:

Member Enumeration Documentation

anonymous enum
Enumerator:
invArmorCount 
invInventoryCount 
invHotbarCount 
invArmorOffset 
invInventoryOffset 
invHotbarOffset 
invNumSlots 

Member Function Documentation

int cInventory::AddItem ( const cItem a_ItemStack,
bool  a_AllowNewStacks = true 
)
Adds as many items out of a_ItemStack as can fit.

If a_AllowNewStacks is set to false, only existing stacks can be topped up; if a_AllowNewStacks is set to true, empty slots can be used for the rest. Returns the number of items that fit.

int cInventory::AddItems ( cItems a_ItemStackList,
bool  a_AllowNewStacks 
)
Same as AddItem, but works on an entire list of item stacks.

The a_ItemStackList is modified to reflect the leftover items. If a_AllowNewStacks is set to false, only existing stacks can be topped up; if a_AllowNewStacks is set to true, empty slots can be used for the rest Returns the total number of items that fit.

void cInventory::Clear ( void  )

Removes all items from the entire inventory.

void cInventory::CopyToItems ( cItems a_Items)

Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents.

bool cInventory::DamageEquippedItem ( short  a_Amount = 1)

Adds the specified damage to the currently held item; deletes the item and returns true if the item broke.

bool cInventory::DamageItem ( int  a_SlotNum,
short  a_Amount 
)

Adds the specified damage to the specified item; deletes the item and returns true if the item broke.

cItemGrid& cInventory::GetArmorGrid ( void  )
inline

Returns the cItemGrid object representing the armor slots.

const cItem& cInventory::GetArmorSlot ( int  a_ArmorSlotNum) const
const cItem& cInventory::GetEquippedBoots ( void  ) const
inline
const cItem& cInventory::GetEquippedChestplate ( void  ) const
inline
const cItem& cInventory::GetEquippedHelmet ( void  ) const
inline
const cItem& cInventory::GetEquippedItem ( void  ) const
const cItem& cInventory::GetEquippedLeggings ( void  ) const
inline
int cInventory::GetEquippedSlotNum ( void  )
inline
cItemGrid& cInventory::GetHotbarGrid ( void  )
inline

Returns the cItemGrid object representing the hotbar slots.

const cItem& cInventory::GetHotbarSlot ( int  a_HotBarSlotNum) const
cItemGrid& cInventory::GetInventoryGrid ( void  )
inline

Returns the cItemGrid object representing the main inventory slots.

const cItem& cInventory::GetInventorySlot ( int  a_InventorySlotNum) const
cPlayer& cInventory::GetOwner ( void  )
inline

Returns the player associated with this inventory.

const cItem& cInventory::GetSlot ( int  a_SlotNum) const
bool cInventory::HasItems ( const cItem a_ItemStack)

Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack.

int cInventory::HowManyCanFit ( const cItem a_ItemStack,
bool  a_ConsiderEmptySlots 
)

Returns number of items out of a_ItemStack that can fit in the storage.

int cInventory::HowManyCanFit ( const cItem a_ItemStack,
int  a_BeginSlotNum,
int  a_EndSlotNum,
bool  a_ConsiderEmptySlots 
)

Returns how many items of the specified type would fit into the slot range specified.

int cInventory::HowManyItems ( const cItem a_Item)

Returns the number of items of type a_Item that are stored.

bool cInventory::RemoveOneEquippedItem ( void  )

Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed.

void cInventory::SetArmorSlot ( int  a_ArmorSlotNum,
const cItem a_Item 
)
void cInventory::SetEquippedSlotNum ( int  a_SlotNum)
void cInventory::SetHotbarSlot ( int  a_HotBarSlotNum,
const cItem a_Item 
)
void cInventory::SetInventorySlot ( int  a_InventorySlotNum,
const cItem a_Item 
)
void cInventory::SetSlot ( int  a_SlotNum,
const cItem a_Item 
)