SRL Archive - OSR Help

Range check error


rj

2013-03-27 18:02:25

I am getting a out of range error at line 19:

{$I SRL/SRL.Simba}
Procedure WalkPoint;
Var
Point_1, Point_2, Spot_Click: TPointArray;
Point_1_ATPA, Point_2_ATPA: T2DPointArray;
X,Y,I,J,Dist_Get_1,Dist_Get_2:Integer;
Begin
FindColorsTolerance(Point_1, 13357521, 531, 30, 712, 193, 15);
FindColorsTolerance(Point_2, 13291472, 531, 30, 712, 193, 15);
SplitTPAWrap(Point_1, 10, Point_1_ATPA);
SplitTPAWrap(Point_1, 10, Point_2_ATPA);
FindColorsTolerance(Spot_Click, 13291472, 649, 308, 664, 323, 25);
SetLength(Point_1, 20);
SetLength(Point_2, 20);
for I:= 0 To High(Point_1) Do
for J:= 0 To High(Point_2) Do
begin
Repeat
Dist_Get_1 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_1[0].x,Point_1[0].y);
Dist_Get_2 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_2[0].x,Point_2[0].y);
If (Dist_Get_1 >= 5) And (Dist_Get_2 >= 5) Then
Begin
mmouse(Spot_Click[0].x,Spot_Click[0].y,1,1)
ClickMouse2(Mouse_Left)
Exit;
End;
Until False;
End;
End;
begin
WalkPoint;
end.

Line 19

Dist_Get_1 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_1[0].x,Point_1[0].y);

I don't understand why I am getting range check..

Rhiot

2013-03-27 19:01:36

Are you sure that
FindColorsTolerance(Spot_Click, 13291472, 649, 308, 664, 323, 25);
is finding any color?
I tested it with different colors really quick and when it found the color it returned no error. Most likely because Spot_Click[0] was never found.

Try a different color and add a length check in the function so the error doesn't appear again.
if (Length(Spot_Click) = 0) then 
Writeln('No colors found!');

Sjoe

2013-03-27 19:03:39

Try adding if (Length(Point_1) < 1) then Exit;

Sin

2013-03-27 19:03:39

You didn't add a length check, (if Length() < 1 then exit;).

Oh never mind, got ninja'd.

Justin

2013-03-27 19:05:17

From: Rhiot
Are you sure that
FindColorsTolerance(Spot_Click, 13291472, 649, 308, 664, 323, 25);
is finding any color?
I tested it with different colors really quick and when it found the color it returned no error. Most likely because Spot_Click[0] was never found.

Try a different color and add a length check in the function so the error doesn't appear again.
if (Length(Spot_Click) = 0) then 
Writeln('No colors found!');


:).

Le Jingle

2013-03-27 19:12:56

Logic appears off, just a heads up for debugging later. (Reasoning : unaccounted for ATPA's, splitting the same TPA into 2 different ATPA's, Finding 3 different TPA's all within a small range of color tolerance, two nested TPA loops with an infinite loop inside, as well as static 0'th indexed values, also forgot a semi-colon) Could very well just be a test snippet though, so hopefully no harm no foul :]

Cheers,
Lj

Justin

2013-03-27 19:25:28

Also why are people still using MMouse then ClickMouse, Why do they forgot that Mouse does all that?

Le Jingle

2013-03-27 19:29:56

From: Justin
Also why are people still using MMouse then ClickMouse, Why do they forgot that Mouse does all that?


I think I also saw you say this on Asha's thread.
While I don't know what other users intentions are, I know that I sometimes like to use MMouse because it's easy to replace with some of the custom mouse functions that aren't currently in the include (like BrakeMMouse, etc.). Thus it's very easy to just replace a called function (from MMouse to BrakeMMouse or vice-verse) without having to edit in and out (or neither), a mouse click. (Just my opinion on the matter)

Sorry for the temp. hijack RJJ! won't continue ;p
Also if you need any help I can offer input too.

Cheers,
Lj

rj

2013-03-27 20:01:54

Ok when I run this it just sits there:

{$I SRL/SRL.Simba}
Procedure WalkPoint;
Var
Point_1, Point_2, Spot_Click: TPointArray;
Point_1_ATPA, Point_2_ATPA, Spot_ATPA: T2DPointArray;
I, J, K, Dist_Get_1, Dist_Get_2, Moves:Integer;
Begin
FindColorsTolerance(Point_1, 228, 547, 33, 710, 193, 25);
FindColorsTolerance(Point_2, 15331301, 547, 33, 710, 193, 25);
FindColorsTolerance(Spot_Click, 6912900, 547, 33, 710, 193, 25);
SplitTPAWrap(Point_1, 15, Point_1_ATPA);
SplitTPAWrap(Point_2, 15, Point_2_ATPA);
SplitTPAWrap(Spot_Click, 15, Spot_ATPA);
SetLength(Point_1, 15);
SetLength(Point_2, 15);
for I:= 0 To High(Point_1) Do
for J:= 0 To High(Point_2) Do
for K:= 0 To High(Spot_Click) Do
begin
Repeat
if (Length(Spot_Click) = 0) or
(Length(Point_1) = 0) or
(Length(Point_2) = 0)then
Begin
Writeln('No colors were found');
Break;
End;
Moves := Moves +1
Dist_Get_1 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_1[0].x,Point_1[0].y);
Dist_Get_2 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_2[0].x,Point_2[0].y);
If (Dist_Get_1 <= 25) and (Dist_Get_2 <= 20) and
(Dist_Get_1 >= 0) and (Dist_Get_2 >= 0) Then
Begin
Writeln('colors were found');
mmouse(Spot_Click[0].x,Spot_Click[0].y,1,1)
ClickMouse2(Mouse_Left)
Exit;
End;
Until Moves > 15
End;
End;
begin
MouseSpeed := 15;
WalkPoint;
end.

Any ideas?