Have a read through the comments:
Simba Code:
Function MithFinder : Boolean; //Make this a function so you know if it worked
var
x, y, z, T, d, CTS, I, H, Count : Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
while (d<100) do
inc(d);
//why not just:
d := 101;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.04,0.3);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 9200996, MSX1, MSY1, MSX2, MSY2, 12);
ColorToleranceSpeed(CTS);
TPAtoATPAExWrap(TPA, 15, 15, ATPA);
Count := InvCount;
H := high(ATPA); //This saves checking it every time (every time)
For i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5); //Increase the randomness
if WaitUptext('ine',900) then
begin
Result := True;
ClickMouse2(mouse_Left);//Use mouse_Left and mouse_Right they read better
MarkTime(T);
Writeln('Minig Mithril')
wait(random(1200));
repeat //Your logic up to here has been great, but what are you doing here?
inc(Z);
writeln('waiting for mithril rock ('+(inttostr(z))+')');
wait(1000+random(250));
until((z>29) or (TimeFromMark(T)>14000+Random(450))); //You don't need a counter and a time marker, choose one
while(Count = InvCount)do //I suggest you replace that repeat function with this...
begin
if(TimeFromMark(T)>14000+Random(450))then
break;
wait(200+Random(1000));
end;
end;
end;
end;