SRL Archive - OSR Advanced Scripting Tutorials

TPoint - TPA's - The Basic's


NiCbaZ

2008-11-17 02:03:43

TPoints, TPA's - The Basics.


Contents
  • Intro.
  • TPoints.
  • TPA's.
  • How to use them.
  • conclusion.



Intro


What Is this Tut? In this Tutorial i will be going around the basics of TPoints and Array of TPoints , ( TPA's), I hope you will learn from it and will iron out all that stuff about them being hard , and that they are really , just easy.



TPoints


What is a TPoint? a TPoint is 2 varables in 1 , Like an X-coord and a Y-coord

TPoint:= Point(X,Y);

or


TPoint:= Point(234,234);

So a TPoint Is just 2 varables in 1, making a Point on the Screen.



TPointArray

What is a TPA? A TPA is basicly an array of TPoints, if you dont what an array is keep read this section ;)
An array of a Tpoint is just lots of Tpoints Like

TPA := [Point(232,234), Point(342,234), Point(123,123)];

TPA's are very usefull in object finding as you can find all the Tpoints ( Point(x,y); on the MainScreen.

il give you a little example, if you finding a tree and you found a Tpoint on each of the tree's branch you could Make the middle of all thoose TPoints (TPA) and make that the place you are going to Click.




*** Waring This Code is not Correct Just an example ***
Procedure FindTPA;
Var
I : Integer;
tpoint : TPoint;
TPA : TPointArray;

begin
TPA := [Point(343,343),Point(354,378),Point(333,654)]; // The TPA

for i:= 0 to length(TPA)-1 do // Defing How Many TPoints we have

Tp:= MiddleTPA(TPA[i]); // Finding the Middle of all the TPoints
end;



So thats basicly how a TPA works.



How To Use Them


How do you use them in your script? Scar has a few ways of using it your script we will use this way…

FindColorsSpiralTolerance(x,y,TPA,Color,MSX1,MSY1,MSX2,MSY2,Tol);


The TPA is what you define your TPA as, the Color is the color you want to find the MSX1, MSX2 ect are the cords of the MainScreen MSX1 = MainSceen X point 1.

Tol is how much tolerance you want.

So the TPA part will Create a TPA of all the Tpoints of Colors It finds.


procedure FindTPA;
var
I : Integer;
TP: Tpoint // our TPoint
TPA: TPointArray // our TPA

begin
FindColorsSpiralTolerance(x,y,TPA,343423,MSX1,MSY1,MSX2,MSY2,8);
for i:= 0 to length(TPA)-1 do
begin
TP:= MiddleTPA(TPA[i]);
MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('TPA') then
begin
Writeln('Found TPA');
Exit;
end;
end;
end;


Now Lets Break this Down

for i:= 0 to length(TPA)-1 do   
begin

This is Defing how many TPoints there are and it will serch Through Each TPoint for the UpText.


TP:= MiddleTPA(TPA[i]);

Making the TPoint out off all the TPA's



MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('TPA') then
begin
Writeln('Found TPA');
Exit;

Moves the Mouse to the location of the Tpoint , and if it Find the UpText it Exits the procedure if it doesnt it moves onto the Next TPoint.



Conclusion


Do you understand? I hope you understaned everything i have typed out , and please if there's an error in there correct me, if you dont understand anything Just post and i will answer you, Look out for my next Tut on Advanced TPA's with the Wizzy Plugin ;).

markuska815

2008-11-17 02:13:04

Since its a one dimensional array wouldnt this be pointless

procedure FindTPA;
var
I : Integer;
TP: Tpoint // our TPoint
TPA: TPoint Array // our TPA

begin
FindColorsSpiralTolerance(x,y,TPA,343423,MSX1,MSY1,MSX2,MSY2,8);
for i:= 0 to length(TPA)-1 do
begin
TP:= MiddleTPA(TPA[i]);
MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('TPA') then
begin
Writeln('Found TPA');
Exit;
end;
end;
end;

shouldnt it just be (and i fixed some small errors too like in definining your vars):

procedure FindTPA;
var
I : Integer;
TP: Tpoint; // our TPoint
TPA: TPointArray; // our TPA

begin
FindColorsSpiralTolerance(x,y,TPA,343423,MSX1,MSY1,MSX2,MSY2,8);
if (Length(TPA) > 0) then
begin
TP:= MiddleTPA(TPA);
MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('Whatever object you want to click on') then
begin
Writeln('Found TPA');
Exit;
end;
end;
end;

Wouldnt what youre doing be for ATPA's where you have multiple tree's… in which you would need to divide the TPA's using SplitTPA () or TPAtoATPA ()?
Or am i just confused

Edit: you also have some spelling errors in the tut itself… contents… conclusion

NiCbaZ

2008-11-17 02:30:12

From: markuska815
Since its a one dimensional array wouldnt this be pointless

procedure FindTPA;
var
I : Integer;
TP: Tpoint // our TPoint
TPA: TPoint Array // our TPA

begin
FindColorsSpiralTolerance(x,y,TPA,343423,MSX1,MSY1,MSX2,MSY2,8);
for i:= 0 to length(TPA)-1 do
begin
TP:= MiddleTPA(TPA[i]);
MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('TPA') then
begin
Writeln('Found TPA');
Exit;
end;
end;
end;

shouldnt it just be (and i fixed some small errors too like in definining your vars):

procedure FindTPA;
var
I : Integer;
TP: Tpoint; // our TPoint
TPA: TPointArray; // our TPA

begin
FindColorsSpiralTolerance(x,y,TPA,343423,MSX1,MSY1,MSX2,MSY2,8);
if (Length(TPA) > 0) then
begin
TP:= MiddleTPA(TPA);
MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('Whatever object you want to click on') then
begin
Writeln('Found TPA');
Exit;
end;
end;
end;

Wouldnt what youre doing be for ATPA's where you have multiple tree's… in which you would need to divide the TPA's using SplitTPA () or TPAtoATPA ()?
Or am i just confused

Edit: you also have some spelling errors in the tut itself… contents… conclusion



Thanks yeah it would be pointless, this tut was mostlty to exsplain What a Tpoint , and TPA is , Not really for a script ;) Thanks for your imput.

markuska815

2008-11-17 02:31:25

yea no problem… but if people are going to try to learn tpoints from this theyll prolly naturally look at that too so itd be good to fix that… but other than that good tut

Narcle

2008-11-17 08:15:03

procedure FindTPA;
var
I : Integer;
TP: Tpoint;
TPA: TPointArray;
ATPA: T2DPointArray;//array of array of TPoint
begin
FindColorsSpiralTolerance(x,y,TPA,343423,MSX1,MSY1,MSX2,MSY2,8);
ATPA := TPAtoATPAEx(TPA, 15, 15);//added for ATPA
for i:= 0 to length(TPA)-1 do
begin
TP:= MiddleTPA(ATPA[i]);
MMouse( TP.x, TP.y, 2, 2,1);
if IsUpText('TPA') then
begin
Writeln('Found TPA');
Exit;
end;
end;
end;

ATPA would be more beneficial since its used more and more versatile. You should add ATPA since it is very important and used just as much as a TPA. Up to you tho, nice Tut other then false code (which imo you should fix).