Code:
program TS_InvCountStack;
{.include srl\srl.scar}
function TS_FindColorsMultiTolerances(var Points: TPointArray; Colors, Tolerances: TIntegerArray; X1, Y1, X2, Y2: Integer): Boolean;
var
I: Integer;
A: TPointArray;
begin
for I := 0 to High(Colors) do
if FindColorsTolerance(A, Colors[I], X1, Y1, X2, Y2, Tolerances[Min(I, High(Tolerances))]) then
Points := CombineTPA(Points, A);
Result := Length(Points) > 0;
end;
function TS_FindColorsMulti(var Points: TPointArray; Colors: TIntegerArray; X1, Y1, X2, Y2: Integer): Boolean;
begin
Result := TS_FindColorsMultiTolerances(Points, Colors, [0], X1, Y1, X2, Y2);
end;
function TS_InvCountStack(var Stack: Integer; Slot: Integer): Boolean;
var
P, T, M: TPointArray;
I: TPoint;
D: T2DPointArray;
N: TStringArray;
C, L, H: Integer;
begin
try
if not GameTab(tab_Inv) and not BankScreen then
Exit;
if (Slot < 1) or (Slot > 28) then
Exit;
if not ExistsItem(Slot) then
Exit;
I := ItemCoords(Slot);
if not TS_FindColorsMulti(P, [65535, 16777215, 8453888], I.X - 20, I.Y - 20, I.X + 20, I.Y) then
Exit;
D := FindGapsTPA(P, 0);
if Length(D) = 0 then
Exit;
N := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'K', 'M'];
for C := 0 to High(D) do
for L := 0 to High(N) do
begin
T := LoadTextTPA(N[L], StatChars, H);
if FindTextTPAinTPA(H, T, D[C], M) then
if L < 10 then
Stack := Stack * 10 + StrToInt(N[L])
else
Stack := Stack * Round(Pow(1000, L - 9));
end;
if Length(IntToStr(Stack)) < Length(D) then
Exit;
Result := True;
finally
case True of
not (GetCurrentTab = tab_Inv) and not BankScreen:
WriteLn('Error: function TS_InvCountStack(Slot: Integer): Integer; -> Unable to open inventory tab.');
(Slot < 1) or (Slot > 28):
WriteLn('Error: function TS_InvCountStack(Slot: Integer): Integer; -> Invalid slot number.');
not ExistsItem(Slot):
WriteLn('Error: function TS_InvCountStack(Slot: Integer): Integer; -> No item in specified slot.');
Length(P) = 0:
WriteLn('Error: function TS_InvCountStack(Slot: Integer): Integer; -> Item is not stackable.');
Length(D) = 0:
WriteLn('Error: function TS_InvCountStack(Slot: Integer): Integer; -> Unable to find numbers.');
Length(IntToStr(Stack)) < Length(D):
WriteLn('Error: function TS_InvCountStack(Slot: Integer): Integer; -> Unable to count the stack.');
end;
end;
end;
var
Stack: Integer;
begin
SetupSRL;
if TS_InvCountStack(Stack, 1) then
WriteLn(Stack)
else
WriteLn('Boo!');
end.
All of my current testing has been accurate, but I am unable to