SRL Archive - OSR Help

Learning atpa's


NexPB

2012-01-10 11:18:30

function FindRange(var x, y: Integer): Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, x1, y1: Integer;

begin
x1 := MSCX;
y1 := MSCY;
FindColorsSpiralTolerance(x1, y1, TPA, 5795972, MSX1, MSY1, MSX2, MSY2, 15);
if Length(TPA) = 0 then FindColorsSpiralTolerance(x1, y1, TPA, 2704732, MSX1, MSY1, MSX2, MSY2, 15);
ATPA := TPAtoATPA(TPA, High(TPA));
for i := 0 to High(ATPA) do
MMouse(ATPA[i].x, ATPA[i].y, 5, 5);// Error at this line.
if (IsUpText('ption')) then
begin
result := true;
end;
end;
end;

Does it looks good its my first time ustin ATPA so im worried a bit also I GET THIS ERROR: [Error] (143:20): Semicolon (';') expected at line 142
Compiling failed.

Flight

2012-01-10 11:26:09

Oh heh yeah, there's a couple things you need to learn about ATPAs to begin with. First off, an ATPA is an array of TPAs, so it's like a double array of points, if that makes any sense… So when you do something like this: "MMouse(ATPA.x, ATPA.y, 5, 5);" you're trying to move the mouse to 1 of those TPAs that exist in the ATPA.

I'm gonna give you a link to the most helpful tutorial there is on TPAs and especially ATPAs. This tutorial will tell you everything you need to know about them and exactly how to use them. Also wonderful examples of use in Runescape.

http://villavu.com/forum/showthread.php?t=49067

Kyle Undefined

2012-01-10 11:26:34

Looking good! :D

To fix the issue, under your "for i := 0 to High(ATPA) do" but a "begin" ;)

Markus

2012-01-10 11:31:59

And use MiddleTPA on one of the TPA's that's part of the ATPA.

Kyle Undefined

2012-01-10 11:35:08

Oh, and if you need to sort the closest one to a point:

SortATPAFrom(ATPA, Point(MSCX, MSCY));

^ Will sort the points from closest to your character, also, may not be exact code, just going from memory.

NexPB

2012-01-10 12:44:15

From: Flight
Oh heh yeah, there's a couple things you need to learn about ATPAs to begin with. First off, an ATPA is an array of TPAs, so it's like a double array of points, if that makes any sense… So when you do something like this: "MMouse(ATPA.x, ATPA.y, 5, 5);" you're trying to move the mouse to 1 of those TPAs that exist in the ATPA.

I'm gonna give you a link to the most helpful tutorial there is on TPAs and especially ATPAs. This tutorial will tell you everything you need to know about them and exactly how to use them. Also wonderful examples of use in Runescape.

http://villavu.com/forum/showthread.php?t=49067

Thanks for the link :)

From: Kyle Undefined
Looking good! :D

To fix the issue, under your "for i := 0 to High(ATPA) do" but a "begin" ;)


Thanks lol stupid from me not to see this -.-

From: Markus
And use MiddleTPA on one of the TPA's that's part of the ATPA.

Oh ok ty.

Main

2012-01-10 13:08:06

Ye like markus said, you need to use middletpa, because atpa returns a tpoint array (which is lots lots of point) rather than just a tpoint.

Very very nice start thou:P
Change This

MMouse(ATPA[i].x, ATPA[i].y, 5, 5);// Error at this line.

to


MMouse( MiddleTPA( ATPA[i]).x, MiddleATPA( ATPA[i]).y, 5, 5);


NexPB

2012-01-10 15:58:04

From: Main
Ye like markus said, you need to use middletpa, because atpa returns a tpoint array (which is lots lots of point) rather than just a tpoint.

Very very nice start thou:P
Change This

MMouse(ATPA[i].x, ATPA[i].y, 5, 5);// Error at this line.

to


MMouse( MiddleTPA( ATPA[i]).x, MiddleATPA( ATPA[i]).y, 5, 5);



function FindRange(var x, y: Integer): Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i: Integer;
PT: TPoint;

begin
FindColorsTolerance(TPA, 5795972, MSX1, MSY1, MSX2, MSY2, 5);
if Length(TPA) = 0 then FindColorsTolerance(TPA, 2704732, MSX1, MSY1, MSX2, MSY2, 5);
ATPA := TPAtoATPA(TPA, High(TPA));
for i := 0 to High(ATPA) do
begin
PT := MiddleTPA(ATPA[i]);
MMouse(PT.x, PT.y, 5, 5);
if (IsUpText('ption')) then
begin
writeln('Found range');
result := true;
end;
end;
end;

I made it like that is that ok?

Flight

2012-01-10 19:24:51

^ That will work fine, although I'm a little confused why you did this:

ATPA := TPAtoATPA(TPA, High(TPA));