How do I find the closest object to the player? I tried this:
Simba Code:
Function PickFlax: Boolean;
Var
tmpCTS,i, L,Counter: Integer;
ObjTPA: TPointArray;
ObjATPA: T2DPointArray;
X,Y,DMCount,Moves: Integer;
Begin
Moves:=0;
DMCount:=0;
tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.07, 0.23);
FindColorsTolerance(ObjTPA, 14999953, MSX1, MSY1, MSX2, MSY2, 5);
SplitTPAWrap(ObjTPA, 10, ObjATPA);
SortATPASize(ObjATPA,True);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
DMCount:=RandomRange(3,5);
L := High(ObjATPA)
MarkTime(Counter);
For i := 0 To L Do
Begin
MiddleTPAEx(ObjATPA[i], X, Y);
Repeat Begin
If (P06_InvFull) Then
Begin
Walk_Bank;
Bank;
End;
Moves:=Moves+1;
mmouse(x, y, 1, 1);
Wait(RandomRange(140, 200));
If (P06_IsUpTextMultiCustom(['Flax','Pick', 'lax','ick'])) Then
Begin
Status := ('Picking flax');
WriteProgress;
clickmouse2(mouse_Left);
Wait(RandomRange(400, 700));
while (IsMoving) do
wait(100);
Exit;
End;
End; Until (Moves > DMCount)
If (TimeFromMark(Counter) > 5000) Then
Begin
Break;
End;
End;
Result:=False;
End;
But it seems to just randomly pick flax around the screen