additional bankscreen functions
Simba Code:
const
BANK_SLOT_LOW = 1;
BANK_SLOT_HIGH = 28;
(*
TRSBankScreen.isSlotVaild
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.isSlotVaild(slot: integer): boolean;
Returns true if the vaild (within the range of 1..28).
.. note::
- by Olly
- Last Updated: 02 January 2013 by Ashaman88
Example:
.. code-block:: pascal
if (bankScreen.isSlotValid(25) then
writeln('Slot 25 is a vaild bankscreen pack slot!');
*)
function TRSBankScreen._isPackSlotVaild(slot: integer): boolean;
begin
result := inRange(slot, BANK_SLOT_LOW, BANK_SLOT_HIGH);
if (not result) then
print('bankScreen._isPackSlotVaild(): Slot '+toStr(slot)+' is invalid', TDebug.WARNING);
end;
(*
TRSBankScreen.isItemInSlot
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.isItemInSlot(slot: integer): boolean;
Returns true if an item is in the desired Bankscreen pack slot, works by looking for
the black outline color in the slot.
.. note::
- by Olly
- Last Updated: 02 January 2013 by Ashaman88
Example:
.. code-block:: pascal
if (bankScreen.isItemInSlot(1)) then
writeln('We have an item in bank pack slot number 1');
*)
function TRSBankScreen.isItemInSlot(slot: integer): boolean;
begin
if (not self.isOpen()) or (not self._isPackSlotVaild(slot))then
exit(false);
result := isItemIn(self.getPackSlotBox(slot));
end;
(*
TRSBankScreen.isFull
~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.isFull: boolean;
Returns true if our bankscreen pack is full.
.. note::
- by Olly
- Last Updated: 02 January 2013 by Ashaman88
Example:
.. code-block:: pascal
if (bankScreen.isFull) then
writeln('our bankscreen pack is full!');
*)
function TRSBankScreen.isFull: boolean;
var
i: integer;
begin
if (not self.isOpen()) then
exit(false);
for i := BANK_SLOT_LOW to BANK_SLOT_HIGH do
if (not (self.isItemInSlot(i))) then
exit(false);
result := true;
end;
(*
TRSBankScreen.isEmpty
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.isEmpty: boolean;
Returns true if our bankscreen pack is empty.
.. note::
- by Olly
- Last Updated: 02 January 2013 by Ashaman88
Example:
.. code-block:: pascal
if (bankScreen.isEmpty) then
writeln('our bankscreen pack is empty!');
*)
function TRSBankScreen.isEmpty: boolean;
begin
if (not self.isOpen()) then
exit(false);
result := (not (self.getBounds().colorExists(ITEM_OUTLINE_BLACK)));
end;
(*
TRSBankScreen.countDTM
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.countDTM(dtm: integer): integer;
Searches for the dtm in each bankscreen pack slot and will return how many matches it finds.
.. note::
- by Olly
- Last Updated: 02 January 2013 by Ashaman88
Example:
.. code-block:: pascal
var
dtm: integer;
i: integer;
begin
dtm := dtmFromString('lotsofstuffhere');
i := bankScreen.countDTM(dtm);
writeln('We counted ' + intToStr(i) + ' items in our bankScreen pack.');
end;
*)
function TRSBankScreen.countDTM(dtm: integer): integer;
var
i, l: integer;
begin
result := 0;
if (not self.isOpen()) then
exit();
result := findItem(dtm, self.getPackSlotBoxes());
if (result = 0) then
begin
print('bankScreen.countDTM(): Found no DTM matches', TDebug.SUB);
exit();
end;
print('bankScreen.countDTM(): Counted ' + intToStr(result) + ' items');
end;
(*
TRSBankScreen.countBitmap
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.countBitmap(bmp, tolerance: integer): integer;
Searches for the bitmap in each bankscreen pack slot and will return how many matches it finds.
.. note::
- by Olly
- Last Updated: 02 January 2013 by Ashaman88
Example:
.. code-block:: pascal
var
bmp: integer;
i: integer;
begin
bmp := bitmapFromString('lotsofstuffhere');
i := bankScreen.countBitmap(dtm);
writeln('We counted ' + intToStr(i) + ' items in our bankSlots.');
end;
*)
function TRSBankScreen.countBitmap(bmp, tolerance: integer): integer;
begin
result := 0;
if (not self.isOpen()) then
exit();
result := findItem(bmp, tolerance, self.getPackSlotBoxes());
if (result = 0) then
begin
print('bankScreen.countBitmap(): Found no bitmap matches', TDebug.SUB);
exit();
end;
print('bankScreen.countBitmap(): Counted ' + intToStr(result) + ' items');
end;
Basically all of these functions are copied from Olly's over at tabbackpack.simba. It's important to have these things if you need to evaluate what's in your pack while you are in the bankscreen.