SRL Archive - OSR Help

out of range error


hackncrack1

2010-05-22 12:04:55

this is out of ranging
Procedure ChopTree;
Var
TP : TPoint;
Time, CTS, L : Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
Begin

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.04, 0.78);

MarkTime(Time);
Repeat
FindColorsTolerance(TPA, 3965556, MSX1, MSY1, MSX2, MSY2, 10);
L := GetArrayLength(TPA);
Until InRange(L, 100, 300) Or (TimeFromMark(Time) < 3500);

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

ATPA := SplitTPA(TPA, 10);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
TP := MiddleTPA(ATPA[0]); <------ here
Mouse(tp.x, tp.y, 2, 0, true);

End;
please help :s

Method

2010-05-22 12:10:06

First of all, it looks like one of your conditions in your until statement is incorrect. Should

(TimeFromMark(Time) < 3500)

be

(TimeFromMark(Time) > 3500)

instead? Then, you should probably also check to see if TPA has any points at all before trying to split it.

Naum

2010-05-22 12:11:21

I'm guessing it'd because your FindColors didn't return anything?
Add a DebugTPA(TPA, ''); after your until statement, see what it returns.

hackncrack1

2010-05-22 12:12:35

thank you, go it fixed :D