Simba Code:
procedure Bank();
var
x, y, i: integer;
TPA: TPointArray; //Unused variable
ATPA: T2DPointArray; //Unused variable
bankTimer: TTimeMarker;
InBank: Tbox; //Unused variable
begin
banktimer.start();
if (bankTimer.getTime() > 120000) and not bankScreen.isOpen() then
TeleportToBank();
mainscreen.findObject(x, y, 7771300, 11, ['ank'], MOUSE_LEFT);
if (not bankScreen.isOpen(8000)) then
begin
if (tabBackpack.count() = 28) then
begin
Bank;
end;
end;
bankScreen.deposit([2], [ - 1]);
bankScreen.close;
tabBackpack.waitWhileLocked;
exit;
Inc(bankfailcount);
if (bankfailcount < 4) then
begin
Bank;
end;
end;
If mainscreen.findObject fails, it will then wait 8 seconds to confirm whether bankscreen.isOpen. Since that will also fail, it will exit the function without increasing fail count because this code...
Simba Code:
Inc(bankfailcount);
if (bankfailcount < 4) then
begin
Bank;
end;
end;
...will never occur since you have exit; before it. So whatever failsafe you intended with that failcount will never happen.
It also seems like your colors are a bit inaccurate if the color search for the bank results in those boxes all over the place.
Calling a function within itself can be confusing unless you truly want to start the entire section of code again. Try using things like attempts instead and having everything laid out clearly in the single function so you can better see the order of events.
Simba Code:
var
attempts: integer;
while attempts < 5 do
begin
doStuff;
if weFailed then
begin
inc(attempts);
writeln('We failed!');
continue;
end;
end;