I'm reading tutorials on CTS2 and will try that.
Here's all the functions involved:
function Full(var MRock : TRSObject) : Boolean;
var
i : Integer;
begin
if not LoggedIn then
Exit;
Result := False;
MRock := GetInteractableAt(MRock.Tile);
for i := 0 to High(RockT) do
begin
if MRock.Tile = RockT[i] then
if MRock.ID = RockIDs[i] then
begin
//Debug('MRock is Full');
Result := True;
Exit;
end;
end;
Debug('MRock is Empty');
end;
function FColorsSpiralTol(colors : TIntegerArray; var TPA : TPointArray; tol : Integer) : Boolean;
var
i : Integer;
Temp, TPA : TPointArray;
begin
TPA := []; //initialize TPA as an empty TPA
for i := 0 to High(colors) do //for all in colors array
begin
FindColorsSpiralTolerance(MSCX, MSCY, Temp, colors[i], MSX1, MSY1, MSX2, MSY2, tol);
TPA := CombineTPA(Temp, TPA); // combine the TPA's
end;
if High(TPA) > 0 then
Result := True;
end;
function MineRocks(var MRock : TRSObject) : Boolean;
var
x, y, i, temp : Integer;
TPA : TPointArray;
PTS : T2DPointArray;
P : TPoint;
begin
if FColorsSpiralTol(RockColors, TPA, 7) then //get TPA
begin
Debug('Found Rock Colors'); //write in debug with timestamp
WriteLn(High(TPA));
MarkTime(temp);
Pts := SplitTPA(TPA, 25); //Split TPA into ATPA Pts
WriteLn('splittpa: ' + Inttostr(TimeFromMark(temp)));
SortATPAFrom(Pts, Point(MSCX, MSCY)); //Sort Pts from center
for i := High(Pts) downto 0 do //Closest point to furthest point
begin
P := MiddleTPA(Pts[i]); //Find midpoint of pts[i]
MRock := GetInteractableAt(MsToClosestTile(P, RockT)); //Get the object at pts[i]
if Full(MRock) then //check if the ID of the object at Pts[i] matches the rock ID at that point
begin
MMouse(P.x, P.y, 3, 3); //Move mouse to the point
GetMousePos(x, y);
Mouse(x, y, 0, 0, True); //Click where the mouse is. Of course, this can be reduced to 1 line, previously it was necessary to have it across 3 lines though.
if DidRedClick then
begin
MRock := GetInteractableAt(MSToClosestTile(Point(x, y), RockT)); //Reset MRock
Result := True; //set result to true
Debug('Ore found at ATPA[' + IntToStr(i) + ']'); //write in the debug
Exit;
end;
end else
Debug('Ore not at ATPA[' + IntToStr(i) + ']');
end;
end;
end;
E: NCDS, I don't want to search just near me because the script will move back and forth between different rocks based on different situations, so I don't want to limit the screen to just the left side or just near me. And as far as your edit goes, I have already done that before, but I've developed a better method of eliminating points which are not rocks. I just lose so much time when converting from tpa to atpa.
E2: Also, this is still in development so it's messy and not the best way to write the function. This will be cleaned up soon as I get the methods working properly.