How do you count stack-able items in your inventory? Like for me I want to count water runes in inventory.
How do you count stack-able items in your inventory? Like for me I want to count water runes in inventory.
ItemAmount function.
From the SRL include:
Simba Code:(*
ItemAmount
~~~~~~~~~~
.. code-block:: pascal
function ItemAmount(area, ItemType: string; Item: Integer; Tol: TIntegerArray): Integer;
Counts the number of items found within the Area (counts stacks).
Parameters are exactly the same as ItemCoordinates.
.. note::
Author: masquerader
Last Modified: Unknown by ZephyrsFury
Example:
.. code-block:: pascal
var
itemsFound: integer;
begin
itemsFound := ItemAmount('inv', 'dtm', dtm_Ore, []);
writeln('Ore found: '+toStr(itemsFound));
end;
*)
function ItemAmount(area, ItemType: string; Item: Integer; Tol: TIntegerArray): Integer;
var
startX, startY, rowSize, colSize, colNumber, rowNumber: integer;
Coords: TPointArray;
i, h: Integer;
begin
Result := 0;
AreaInfo(area, startX, startY, rowSize, colSize, colNumber, rowNumber);
Coords := ItemCoordinates(Area, ItemType, Item, Tol);
h := High(Coords);
for i := 0 to h do
Result := Result + GetAmountBox(IntToBox(Coords[i].x - floor(rowSize / 2),
Coords[i].y - floor(colSize / 2),
Coords[i].x + floor(rowSize / 2),
Coords[i].y + floor(colSize / 4)));
end;
I am Ggzz..
Hackintosher
ah thanks I was trying to use CountItem but I see why it wasn't working
function GetAmountBox(box: TBox): integer;
Ex.
Simba Code:{$i srl/srl.simba}
var
amount : Integer;
b: TBox;
begin
SetupSRL;
b := InvBox(1); // creates a box from the first inventory slot.
amount := GetAmountBox(b); // counts the text in that first slot ^
writeln(amount);
end.
edit:'d
What about items in the bank?
Here's what I used in my fletcher (prob outdated section now)
Simba Code:procedure CountItemCheck;
var
count: Integer;
b: TBox;
begin
if (bankscreen) then
begin
b := BankIndexToMSBox(BankPointToBankIndex(Point(9, 0)));
count := GetAmountBox(b);
Writeln('Items Remaining = ' + IntToStr(count) + '.');
if (count < 100) then
begin
Writeln('Almost out of supplies! -> CIAO / TERMINATING SCRIPT');
TerminateScript;
end;
end;
end;
^ Just more boxes. Could use a DTM/count colors/etc. (ex. to find the item in bank) to pass parameters for it too, the one I have above is static
Ah, I see, thanks![]()
Or, simpler, getting the number of items out of a TP:
Simba Code:GetBankItemAmount(((TP.x - 38) div 44), ((TP.y - 90) div 45)) < 50)
Same function can be used if you know the coordinates too (like 0, 0). The formulas I'm using are to transform a TP into a bank row and column.
There are currently 1 users browsing this thread. (0 members and 1 guests)