icode
2015-02-24 22:57:25
Here is the code snippet I have for my miner I am working on. This is the function that finds the iron ore rocks and clicks on them. The only problem I am having is that it will find all the rocks on the screen, but then quickly click all of them. I just want it to find one and click on one, but I can't seem to fix this problem. Any help would be appreciated.
function FindRocks(x, y: Integer): Boolean;
var
MyTPA: TPointArray;
MMTPA: TPoint;
MyATPA: T2DPointarray;
attempts, TPAL, CTS, i: Integer;
PBox: TBox;
begin
attempts := 0 CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.17, 0.75);
FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, 1450296, MSx1, MSy1, MSx2, MSy2, 9);
ColorToleranceSpeed(CTS);
if Length(MyTPA) = 0 then
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.25, 0.82);
FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, 2898528, MSx1, MSy1, MSx2, MSy2, 2);
ColorToleranceSpeed(CTS);
end;
SMART_DrawDots(MyTPA);
MyATPA := tpatoatpaex(mytpa, 40, 40);
TPAL := High(MyATPA);
for i := TPAL downto 0 do
begin
MMTPA := MiddleTPA(MyATPA[i]);
MMouse(MMTPA.x, MMTPA.y, 3, 3);
if (waitUpTextMulti(['ine', 'roc'], 600)) then
begin
Result := True;
ClickMouse2(Mouse_Left);
end
else
begin
Writeln('option mine rock not found') Attempts := + 1;
if Attempts >= 30 then
begin
WriteLn('can not find Iron in MainScreen, logging out');
Logout;
TerminateScript;
end;
end;
end;
end;