SRL Archive - OSR Outdated Tutorials

Objects for the beginners


Smarter Child

2009-08-28 02:02:07

Objects For The Beginners!


Hi everybody! Today I am going to be writing a brief tutorial on objects and go through the mainly used functions in object.scar.

Q: What is object finding?
A: Object finding is finding objects in runescape, whether it be trees/rocks/fishing spots/lobsters etc.

Q: Why should i read this tutorial, how are objects going to ever be helpful in scripting?
A: Objects are everywhere in runescape, they're a big thing, and sometimes people get too lazy to do TPointArrays(more advanced).

So lets go through the include….


function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol, Step, xs, ys, xe, ye: Integer): Boolean;

This function, is a very accurate function, basically you can find almost anything in runescape with this ;).

Explanation: The parameters are fairly easy but i will write an example showing you how this function works.

Procedure FindTree;
var
x, y: integer; //The coordinates of the object will be stored in x/y
begin
FindObjectEx(x, y, ['Tree', 'ree'], [34525, 256436, 4265346, 2423432], 25, 50, MSX1, MSY1, MSX2, MSY2);
end;

Don't get too :confused: just yet, its very simple.

x, y: these are the coordinates so the mouse can move to this position later.

['Tree', 'ree']: This is the uptext on the top left corner of the screen, this is like a failsafe, so the mouse doesn't click anything only with that color, you can have as many uptexts as you want.

[34525, 256436, 4265346, 2423432]: These are the colors of the tree which you can get using the color picker(CTRL + P), you can have as many colors as you want here, although you don't need much ;).

25: this is the tolerance, i just used 25, since its a general number, this high of a tol may or not be need to find the object.

50: These are size of the search squares, according to the include 50 is default, so i left as is. (Average 30-70).

MSX1, MSY1, MSX2, MSY2: These are the mainscreen coordinates.

Pretty simple eh, you can do:

Procedure FindTree;
var
x, y: integer; //The coordinates of the object will be stored in x/y
begin
if FindObjectEx(x, y, ['Tree', 'ree'], [34525, 256436, 4265346, 2423432], 25, 50, MSX1, MSY1, MSX2, MSY2)then
Mouse(x, y, 2, 2, true);
end;

You don't need to do mmouse(x, y, 2, 2) then check uptext since findobjectex does that for you! (You must click).

————

function FindObj(var cx, cy: Integer; Text: string; Color: Integer; Tol: Integer): Boolean;

Explanation: Its pretty much like FindObjectEx except you can only use 1 color, 1 uptext. I will show you and example:

Procedure FindTree;
var
x, y: integer; //coords
begin
if FindObj(x, y, 'Tree', 4536362, 15)then
Mouse(x, y, 2, 2, true);
end;

This can be a little easier to work with, but it isn't as flexible as FindObjectEx.

————-

function FindObjCustom(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol: Integer): Boolean;

Explanation: This too is similar to FindObjectEx, but you can use a custom amount of colors and uptexts unlike FindObject. Example:

Procedure FindTree;
var
x, y: integer; //coords
begin
if FindObjCustom(x, y, ['Tree', 'ree'], [34256, 435366, 345346], 14)then
Mouse(x, y, 2, 2, true);
end;

————

function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;

Explanation: AHhh, this is one of my favourites ;P. FindObjTPA, is probably the EASIEST TPA you will ever get to make in your life.:

Procedure FindObject;
var
x, y: integer; //coords
begin
if FindObjTPA(x, y, 5436721, 15, -1, 25, 25, 1, ['bject', 'Object'])then
begin
Writeln('YAY');
Mouse(x, y, 3, 3, true);
end;
end;

Now this function can be a little confusing, but i will explain everything to my understand for you ;).

x, y: these are the coordinates

5436721: the color of the object

15: This is my tolerance, you can set higher or lower depending on how hard it is to find the color.

-1: This is CTS aka color tolerance speed, you can either have -1, 1, 2, 3:

-1 doesn't changed the color tolerance speed, as you get to 1,2,3 the accuracy increases, but it can get sensitive. If your a more advanced scripter or your finding an object thats hard to find then change this to how you like.

25: the objects width in pixels. <–>

25: the objects height in pixels. ^ : vertically

1: The minimum amount of colors you should find at the object, this depends solely on the colors of the object, i left mine at 1 since you should at least find 1 color at an object

['bject', 'object']: this is the uptext, you can have more than one uptext in this one.

That is basically a brief yet good(hopefully :p) explanation on FindObjTPA.

Before concluding my tutorial i will show you guys how to use more than one colors in findobjtpa:

Procedure FindObject;
var
x, y: integer; //coords
Colors: TIntegerArray; //More than one integere
begin
Colors := [3526, 363745748, 326325432, 345345632]; //Array of colors
For i := 0 to 3 do //for i := the amount of colors, including 0, so its 0 to 3 since there are 4 colors, it'd be 0 to 4 with 5 colors, understand?
begin
if FindObjTPA(x, y, Colors[i], 15, -1, 25, 25, 1, ['bject', 'Object'])then //since its an array the color should be Colors[i].
begin
Writeln('YAY');
Mouse(x, y, 3, 3, true);
break; //or exit, if you want to exit THIS entire procedure, thanks baked :)
end;
end;
end;

Everything should be explained in the tags :p.

Good luck making your own, much more failsafed, object finding functions.

:).

~~ END ~~

Rich

2009-08-28 12:52:07

Nice tutorial. I think this will definitely help the beginners. Since the tutorial is about object finding, you could add about the FindColor functions, and maybe DTMs and Bitmaps?

Richard.

Smarter Child

2009-08-28 15:17:34

From: R1ch
Nice tutorial. I think this will definitely help the beginners. Since the tutorial is about object finding, you could add about the FindColor functions, and maybe DTMs and Bitmaps?

Richard.


Perhaps, that would be a little massive. I might do more advanced methods in part 2 in intermediate section ;).

Thanks~

Alligaattor

2009-08-31 21:53:55

that last example works but after it clicks it, finding doesn't end… just keeps looking for that object :S
yes, i put setupsrl; in my mainloop;

Baked0420

2009-08-31 22:28:20

to make it stop do:




Procedure FindObject;
var
x, y: integer; //coords
Colors: TIntegerArray; //More than one integere
begin
Colors := [3526, 363745748, 326325432, 345345632]; //Array of colors
For i := 0 to 3 do //for i := the amount of colors, including 0, so its 0 to 3 since there are 4 colors, it'd be 0 to 4 with 5 colors, understand?
begin
if FindObjTPA(x, y, Colors[i], 15, -1, 25, 25, 1, ['bject', 'Object'])then //since its an array the color should be Colors[i].
begin
Writeln('YAY');
Mouse(x, y, 3, 3, true);
break; //or exit, if you want to exit THIS entire procedure
end;
end;
end;


all I did was add a break underneath where it clicks, to make it break out of the for to do loop, alternatively, you can exit the entire findobject; procedure by changing break; to exit;

you may want to add that little piece to your procedure in there Smarter ;)

but very nice tut, this could've helped me a lot when I was first starting out.

Smarter Child

2009-09-01 05:40:04

Haha, thanks baked, i'll add that to the tutorial.

fifa499

2009-09-01 07:21:18

With this
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol, Step, xs, ys, xe, ye: Integer): Boolean;

And this it will work as find anything in rs?

Procedure FindObject;
var
x, y: integer; //coords
Colors: TIntegerArray; //More than one integere
begin
Colors := [3526, 363745748, 326325432, 345345632]; //Array of colors
For i := 0 to 3 do //for i := the amount of colors, including 0, so its 0 to 3 since there are 4 colors, it'd be 0 to 4 with 5 colors, understand?
begin
if FindObjTPA(x, y, Colors[i], 15, -1, 25, 25, 1, ['bject', 'Object'])then //since its an array the color should be Colors[i].
begin
Writeln('YAY');
Mouse(x, y, 3, 3, true);
break; //or exit, if you want to exit THIS entire procedure
end;
end;
end;

Awkwardsaw

2009-09-01 07:27:39

From: fifa499
With this
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol, Step, xs, ys, xe, ye: Integer): Boolean;

And this it will work as find anything in rs?

Procedure FindObject;
var
x, y: integer; //coords
Colors: TIntegerArray; //More than one integere
begin
Colors := [3526, 363745748, 326325432, 345345632]; //Array of colors
For i := 0 to 3 do //for i := the amount of colors, including 0, so its 0 to 3 since there are 4 colors, it'd be 0 to 4 with 5 colors, understand?
begin
if FindObjTPA(x, y, Colors[i], 15, -1, 25, 25, 1, ['bject', 'Object'])then //since its an array the color should be Colors[i].
begin
Writeln('YAY');
Mouse(x, y, 3, 3, true);
break; //or exit, if you want to exit THIS entire procedure
end;
end;
end;


yes, it should :) just remember to change the colors and uptext :) also, i would make -1 to 3, and 15 to around 5-7

fifa499

2009-09-01 07:30:38

From: Awkwardsaw
yes, it should :) just remember to change the colors and uptext :) also, i would make -1 to 3, and 15 to around 5-7


thank-you very much and thank-you smarter child rep+

Smarter Child

2009-09-02 02:56:04

From: fifa499
thank-you very much and thank-you smarter child rep+


No problemos. I live to help. :)