PDA

View Full Version : Guide to tpas, and how to use them!



Awkwardsaw
08-11-2009, 11:42 AM
This guide will(hopefully) teach you what a tpa is, how it works, and so on and so forth :p

Under standing a TPoint

A TPA is a TPointArray, before you can fully understand WHAT it is, you must know 2 other "vocabularies", which is a "TPoint", and an "Array". I wont go into what an array is, since you should already know, but if not there are plenty of tutorials out there that explain it very well :)

So, that leaves the TPoint. A tpoint, is pretty much a type, that can hold the x and y value of a point.

it looks something like this:

type
TPoint = record
x : integer;
y : integer;
end;

I'm not sure if i can explain why its like that, but i can explain hows its used.

program New;
{.Include SRL/SRL.scar}

var TP : TPoint; //you call TP as a TPoint
begin
TP := point(100, 200); //the function point returns a TPoint, 100 being the x value and 200 being the y value.
mousespeed := 10;
mmouse(TP.x, TP.y, 0, 0); //you can use these values to substitute
end.

this is a basic example of a tpoint. of course, this isn't very useful, nor efficient, but it shows some-what how its used.

lets use a function in srl, called:

function ItemCoords(i: Integer): TPoint;

as you can see, its a function that returns a TPoint, and this is how you would use it in a script:

program New;
{.Include SRL/SRL.scar}

var TP : TPoint; i : integer;

begin
for i:= 1 to 28 do
begin
TP:= ItemCoords(i); //Item Coords returns the x and y value of item 1
//in a TPoint
mmouse(tp.x, tp.y, 5, 5); //And you use tp's x and y values
//To move your mouse over the item
if isuptext('opper') then
dropitem(i);
end;
end.

once again, this wouldn't be to good in runescape, but its also a good example. It uses a for-to-do loop to get the item coords of the item, moves the mouse to each one, and if the uptext of "opper" is found, it will drop that item, you see?

Now that you know what a TPoint is, we shall go onto the TPointArray

TPointArrays!!
Finally :) the meat of the tutorial. a TPA is literally, an array of a TPoint

type
TPointArray = array of TPoint;


and a basic example:

program New;
{.Include SRL/SRL.scar}

var TPA : TPointArray; i : integer;

begin
TPA := [point(100, 100), point(200, 200)]; //points return a TPoint
//And its in an array,
//thus creating a TPointArray
mousespeed := 10;
for i:= 0 to 1 do mmouse(TPA[i].x, TPA[i].y, 0, 0);
end.

honestly, this is the same thing as simply doing

begin
mmouse(100, 100, 0, 0);
mmouse(200, 200, 0, 0);
end.

but thats not the point :) because when your using this in runescape, there will most likly be A LOT of points, probably 100 +.

this is a basic tree finding function using tpas:
function findtree : boolean;
var tpa : tpointarray; I : integer;
begin
if findcolorstolerance(TPA, {color}, msx1, msy2, msx2, msy2, 10) then
for i:= 0 to high(tpa) do
begin
mmouse(tpa[i].x, tpa[i].y, 0, 0);
if isuptext('ree') then
begin
result := true;
exit;
end;
end;
end;

You are probably all "z0mg lots of stuff", but really, its quite easy, especially if you are 100% familiar with the TPoint, and arrays. but lets break it down shall we?

var tpa : tpointarray; I : integer; is our variable declaration, we need a TPA variable and an integer variable

if findcolorstolerance(TPA, {color}, msx1, msy2, msx2, msy2, 10) then

this is a basic function used to find tpas. TPA is the name of our TPointArray, you can replace {color} with any thing really, and msx1, ect ect are the mainscreen variables. 10 is our tolerance. its really simple isnt it?

for i:= 0 to high(tpa) do
begin

this starts our loop, high(tpa) incase you didnt know, returns the highest value in the array "tpa".

mmouse(tpa[i].x, tpa[i].y, 0, 0);

i honestly think this is the hardest part of the entire tutorial. its hard for me to explain, so sorry if its not that good. :(

what this will do is it moves the mouse to the TPoint in the array, and if you know what a tpoint is i shouldn't really have to explain it to much, the same goes if you know how to use arrays and for-to-do loops

if isuptext('ree') then
begin
result := true;
exit;
end;

this should be simple, if it finds the uptext then the function returns true and exits.

Conclusion
TPAs are what most scripts use for object finding. it is the most powerful object finder using color imo, and im sure the rest agree.

its late at night, so im getting tired, and i have school in the morning so i have to get to bed :( i know i should have gone into more detail about certain things, so dont hold it against me :p although do post parts that i need to improve on, grammar, spelling, detail, and script wise so i can fix it up in the morning/ tomorrow night

thanks for reading :D ~awkwardsaw

Sir R. M8gic1an
08-12-2009, 05:44 AM
moved.

~RM

Awkwardsaw
08-12-2009, 05:49 AM
tpas should be in advanced? sorry :o. i guess i should have paid more attention to that sticky ;) i'll go through this tonight hopefully to fix things up and such

Mr. Doctor
08-16-2009, 07:54 PM
On your tree finding function you have


msx1, msy2, msx2, msy2.

same explaining it.
Other then that awesome 1 more thing i learned.

Awkwardsaw
08-17-2009, 04:50 AM
:p thanks, i guess haha

Smarter Child
08-23-2009, 01:17 AM
Dude, this is like intermediate, very simple stuff man!

NCDS
08-23-2009, 01:35 AM
Probably wouldn't hurt to go a bit more in detail with it. Explain how to manipulate them a bit maybe? Actually show what they are capable of.

Awkwardsaw
08-23-2009, 02:06 AM
Smarter Child, it was in intermediet, it was moved :p

and i havnt had time to work on it, and im not planning on it for a while :p but it is on my to-do list

Mr. Doctor
09-01-2009, 05:53 AM
:p thanks, i guess haha

If you didn't know what i meant, change

msx1,msy2,msx2,msy2 to

msx1,msy1,msx2,msy2

And it has the same problem when your explaining it. I see i made no sense in my post when i tried telling you the problem.

Rich
09-01-2009, 03:58 PM
If you was finding a tree, you would use FindColorsSpiralTolerance. Also, perhaps add about TPAToATPA and SplitTPA, and the Ex versions of them.

Richard.

Awkwardsaw
09-02-2009, 06:19 AM
If you was finding a tree, you would use FindColorsSpiralTolerance. Also, perhaps add about TPAToATPA and SplitTPA, and the Ex versions of them.

Richard.

yes, spiral is best to use, and atpas are more advanced for this, dont you think?

any who, i might update this guide tonight if i feel like it