This guide will(hopefully) teach you what a tpa is, how it works, and so on and so forth
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:
SCAR Code:
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.
SCAR Code:
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:
SCAR Code:
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:
SCAR Code:
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
SCAR Code:
type
TPointArray = array of TPoint;
and a basic example:
SCAR Code:
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
SCAR Code:
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:
SCAR Code:
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?
SCAR Code:
var tpa : tpointarray; I : integer;
is our variable declaration, we need a TPA variable and an integer variable
SCAR Code:
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?
SCAR Code:
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".
SCAR Code:
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
SCAR Code:
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 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 ~awkwardsaw