SRL Archive - OSR Help

MiddleTPA


CephaXz

2012-06-25 18:29:44

It works if I type it like this


TheThing := FindTPointCluster([1721945,1258561,1026,1580059,531240], 10, Point(647, 147), -1, -1, 10, MMX1, MMY1, MMX2, MMY2);
ATPA := TPAtoATPAEx(TheThing, 3,3);
writeln('Walking to log');
for i := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[i]); //I would only want i=0
SMART_DrawCircle(true, MP, 15, false, clRed);
Mouse(MP.x, MP.y, 5, 5, mouse_Left);
repeat
wait(10);
until InsideArea(0, ['9_2','9_1'], 3843, 839, 3847, 847);
Break;
end;

But since I only want the first result, why can't I do this? It returns an error:Out of range


TheThing := FindTPointCluster([1721945,1258561,1026,1580059,531240], 10, Point(MMCX, MMCY), -1, -1, 10, MMX1, MMY1, MMX2, MMY2);
ATPA := TPAtoATPAEx(TheThing, 3,3);
writeln('Loging');
MP := MiddleTPA(ATPA[0]); //Error here
SMART_DrawCircle(true, MP, 15, false, clRed);
ThePoint := MMtoMS(MP);
Mouse(ThePoint.x+30, ThePoint.y+10, 3, 3, mouse_Right);
if WaitOption('ross', 2000) then
begin
repeat
wait(10);
until MyPos(Point(3815, 847));
Result := True;
end;

Tniffoc

2012-06-25 18:38:32

Hmm that's odd. Try printing out the length of ATPA before the line to make sure thats its actually getting filled in that version.

CephaXz

2012-06-25 18:40:57

You mean something like this?


if Length(ATPA) > 0 then
MP := MiddleTPA(ATPA[0]);

Tniffoc

2012-06-25 18:43:12

Well I'm just debugging it. I just want you to print out the length before the error so we can narrow down where the error is. Just something like this:

Writeln('Length: ' + intToStr(length(ATPA)));
MP := MiddleTPA(ATPA[0]);

EDIT: Please tell me what it says once you've done this if you would be so kind.

CephaXz

2012-06-25 18:49:56

Returns length of 2. And now it works again. But when it gives me the error some time later, it would give me the error forever until I restart Simba.

Tniffoc

2012-06-25 18:51:54

Well the reason for that is that nothing is actually being found when you search the colors (most likely). This probably means that your client go unset or SMART crashed depending on whether or not you are using SMART.

CephaXz

2012-06-25 19:06:29

You're right, it returns 0 for me sometimes. Guess I need to do a little fix on the function. Thanks!