You should exit your procedure if you didn't find any colours (if length(TPA) < 1). If you try and split an empty TPA into an ATPA it will most likely throw an error (see below for simple fix).
When you go: ATPA.filterBetween(8, 10); you are removing any TPAs with between 8 and 10 pixels. Do you want to retain the TPAs with only 3 matching TPoints?
Also if you:
Simba Code:
mouseBox(ATPA[i].getBounds(), MOUSE_MOVE);
it won't click the midpoint of the TPA, but somewhere inside it's bounds, with a higher change of clicking closer to the middle. If you want a completely random point, you can:
Simba Code:
mouse(ATPA[i].getBounds().getRandomPoint(), MOUSE_MOVE);
Simba Code:
procedure Bank();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
bankTimer: TTimeMarker;
InBank : Tbox;
begin
banktimer.start();
InBank := IntToBox(346,170,362,186); //what is this used for?
repeat
if (bankTimer.getTime() > 60000) then
TeleportToBank();
findColorsSpiralTolerance(x, y, TPA, BANKER_COLOR, mainScreen.getBounds(), 20, colorSetting(BANKER_TOL, BANKER_SAT, BANKER_HUE));
if (Length(TPA) < 1) then
begin
writeLn('no banker"s found!');
exit;
end;
ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(8, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);
for i := 0 to high(ATPA) do
begin
mouseBox(ATPA[i].getBounds(), MOUSE_MOVE);
if isMouseOverText(['Bank','ank','Banker','anker'], 500) then
fastClick(MOUSE_LEFT);
end;
smartImage.clear;
until bankScreen.isOpen();
wait(randomRange(500, 1000));
bankScreen.deposit([2..28]);
wait(randomRange(500, 1000));
BankScreen.close();
wait(randomRange(500, 2000));
end;