API
Functions and classes available in the Lua API
|
#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. | |
cItemGrid & | GetArmorGrid (void) |
Returns the cItemGrid object representing the armor slots. | |
const cItem & | GetArmorSlot (int a_ArmorSlotNum) const |
const cItem & | GetEquippedBoots (void) const |
const cItem & | GetEquippedChestplate (void) const |
const cItem & | GetEquippedHelmet (void) const |
const cItem & | GetEquippedItem (void) const |
const cItem & | GetEquippedLeggings (void) const |
int | GetEquippedSlotNum (void) |
cItemGrid & | GetHotbarGrid (void) |
Returns the cItemGrid object representing the hotbar slots. | |
const cItem & | GetHotbarSlot (int a_HotBarSlotNum) const |
cItemGrid & | GetInventoryGrid (void) |
Returns the cItemGrid object representing the main inventory slots. | |
const cItem & | GetInventorySlot (int a_InventorySlotNum) const |
cPlayer & | GetOwner (void) |
Returns the player associated with this inventory. | |
const cItem & | GetSlot (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) |
This class represents the player's inventory
The slots are divided into three areas:
anonymous enum |
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.
|
inline |
Returns the cItemGrid object representing the armor slots.
const cItem& cInventory::GetArmorSlot | ( | int | a_ArmorSlotNum | ) | const |
|
inline |
|
inline |
|
inline |
const cItem& cInventory::GetEquippedItem | ( | void | ) | const |
|
inline |
|
inline |
|
inline |
Returns the cItemGrid object representing the hotbar slots.
const cItem& cInventory::GetHotbarSlot | ( | int | a_HotBarSlotNum | ) | const |
|
inline |
Returns the cItemGrid object representing the main inventory slots.
const cItem& cInventory::GetInventorySlot | ( | int | a_InventorySlotNum | ) | const |
|
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 | ||
) |