API
Functions and classes available in the Lua API
|
#include <0017.h>
Public Member Functions | |
int | AddItem (cItem &a_ItemStack, bool a_AllowNewStacks=true) |
int | AddItems (cItems &a_ItemStackList, bool a_AllowNewStacks=true) |
int | ChangeSlotCount (int a_SlotNum, int a_AddToCount) |
int | ChangeSlotCount (int a_X, int a_Y, int a_AddToCount) |
void | Clear (void) |
Sets all items as empty. | |
void | CopyToItems (cItems &a_Items) const |
Copies the contents into a cItems object; preserves the original a_Items contents. | |
bool | DamageItem (int a_SlotNum, short a_Amount) |
Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact) | |
bool | DamageItem (int a_X, int a_Y, short a_Amount) |
Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact) | |
void | EmptySlot (int a_X, int a_Y) |
void | EmptySlot (int a_SlotNum) |
int | GetFirstEmptySlot (void) const |
Returns the index of the first empty slot; -1 if all full. | |
int | GetFirstUsedSlot (void) const |
Returns the index of the first non-empty slot; -1 if all empty. | |
int | GetHeight (void) const |
int | GetLastEmptySlot (void) const |
Returns the index of the last empty slot; -1 if all full. | |
int | GetLastUsedSlot (void) const |
Returns the index of the last used slot; -1 if all empty. | |
int | GetNextEmptySlot (int a_StartFrom) const |
Returns the index of the first empty slot following a_StartFrom (a_StartFrom is not checked) | |
int | GetNextUsedSlot (int a_StartFrom) const |
Returns the index of the first used slot following a_StartFrom (a_StartFrom is not checked) | |
int | GetNumSlots (void) const |
const cItem & | GetSlot (int a_X, int a_Y) const |
const cItem & | GetSlot (int a_SlotNum) const |
int | GetSlotNum (int a_X, int a_Y) const |
Converts XY coords into slot number; returns -1 on invalid coords. | |
int | GetWidth (void) 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) |
Returns number of items out of a_ItemStack that can fit in the storage. | |
int | HowManyItems (const cItem &a_Item) |
Returns the number of items of type a_Item that are stored. | |
cItem | RemoveOneItem (int a_SlotNum) |
cItem | RemoveOneItem (int a_X, int a_Y) |
void | SetSlot (int a_X, int a_Y, const cItem &a_Item) |
void | SetSlot (int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage) |
void | SetSlot (int a_SlotNum, const cItem &a_Item) |
void | SetSlot (int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage) |
Protected Member Functions | |
void | TriggerListeners (int a_SlotNum) |
Calls all m_Listeners for the specified slot number. |
Protected Attributes | |
cCriticalSection | m_CSListeners |
CS that guards the m_Listeners against multi-thread access. | |
int | m_Height |
bool | m_IsInTriggerListeners |
Set to true while TriggerListeners is running, to detect attempts to manipulate listener list while triggerring. | |
cListeners | m_Listeners |
Listeners which should be notified on slot changes; the pointers are not owned by this object. | |
int | m_NumSlots |
cItem * | m_Slots |
int | m_Width |
int cItemGrid::AddItem | ( | 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 cItemGrid::AddItems | ( | cItems & | a_ItemStackList, |
bool | a_AllowNewStacks = true |
||
) |
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.
int cItemGrid::ChangeSlotCount | ( | int | a_SlotNum, |
int | a_AddToCount | ||
) |
Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
If the slot is empty, ignores the call. Returns the new count.
int cItemGrid::ChangeSlotCount | ( | int | a_X, |
int | a_Y, | ||
int | a_AddToCount | ||
) |
Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
If the slot is empty, ignores the call. Returns the new count.
void cItemGrid::Clear | ( | void | ) |
Sets all items as empty.
void cItemGrid::CopyToItems | ( | cItems & | a_Items | ) | const |
Copies the contents into a cItems object; preserves the original a_Items contents.
bool cItemGrid::DamageItem | ( | int | a_SlotNum, |
short | a_Amount | ||
) |
Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact)
bool cItemGrid::DamageItem | ( | int | a_X, |
int | a_Y, | ||
short | a_Amount | ||
) |
Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact)
void cItemGrid::EmptySlot | ( | int | a_X, |
int | a_Y | ||
) |
void cItemGrid::EmptySlot | ( | int | a_SlotNum | ) |
int cItemGrid::GetFirstEmptySlot | ( | void | ) | const |
Returns the index of the first empty slot; -1 if all full.
int cItemGrid::GetFirstUsedSlot | ( | void | ) | const |
Returns the index of the first non-empty slot; -1 if all empty.
|
inline |
int cItemGrid::GetLastEmptySlot | ( | void | ) | const |
Returns the index of the last empty slot; -1 if all full.
int cItemGrid::GetLastUsedSlot | ( | void | ) | const |
Returns the index of the last used slot; -1 if all empty.
int cItemGrid::GetNextEmptySlot | ( | int | a_StartFrom | ) | const |
Returns the index of the first empty slot following a_StartFrom (a_StartFrom is not checked)
int cItemGrid::GetNextUsedSlot | ( | int | a_StartFrom | ) | const |
Returns the index of the first used slot following a_StartFrom (a_StartFrom is not checked)
|
inline |
const cItem& cItemGrid::GetSlot | ( | int | a_X, |
int | a_Y | ||
) | const |
const cItem& cItemGrid::GetSlot | ( | int | a_SlotNum | ) | const |
int cItemGrid::GetSlotNum | ( | int | a_X, |
int | a_Y | ||
) | const |
Converts XY coords into slot number; returns -1 on invalid coords.
|
inline |
bool cItemGrid::HasItems | ( | const cItem & | a_ItemStack | ) |
Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack.
int cItemGrid::HowManyCanFit | ( | const cItem & | a_ItemStack | ) |
Returns number of items out of a_ItemStack that can fit in the storage.
int cItemGrid::HowManyItems | ( | const cItem & | a_Item | ) |
Returns the number of items of type a_Item that are stored.
cItem cItemGrid::RemoveOneItem | ( | int | a_SlotNum | ) |
Removes one item from the stack in the specified slot, and returns it.
If the slot was empty, returns an empty item
cItem cItemGrid::RemoveOneItem | ( | int | a_X, |
int | a_Y | ||
) |
Removes one item from the stack in the specified slot, and returns it.
If the slot was empty, returns an empty item
void cItemGrid::SetSlot | ( | int | a_X, |
int | a_Y, | ||
const cItem & | a_Item | ||
) |
void cItemGrid::SetSlot | ( | int | a_X, |
int | a_Y, | ||
short | a_ItemType, | ||
char | a_ItemCount, | ||
short | a_ItemDamage | ||
) |
void cItemGrid::SetSlot | ( | int | a_SlotNum, |
const cItem & | a_Item | ||
) |
void cItemGrid::SetSlot | ( | int | a_SlotNum, |
short | a_ItemType, | ||
char | a_ItemCount, | ||
short | a_ItemDamage | ||
) |
|
protected |
Calls all m_Listeners for the specified slot number.
|
protected |
CS that guards the m_Listeners against multi-thread access.
|
protected |
|
protected |
Set to true while TriggerListeners is running, to detect attempts to manipulate listener list while triggerring.
|
protected |
Listeners which should be notified on slot changes; the pointers are not owned by this object.
|
protected |
|
protected |
|
protected |