SRL Archive - OSR Help

HELP Restricting Area


Recursive

2012-05-16 02:08:08

I want to find an object on the screen, but I want to restrict the searching to only a specific area instead of the entire screen. How do I do this?

John

2012-05-16 02:14:32

(*
FindObjEx
~~~~~~~~~

.. code-block:: pascal

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

Searches for an object using an array of colors and texts within the area
you specify. Will start searching from the middle and returns true if found.
Parameters:

- cx, cy: Coordinate Position of object if result is true
- Text: Array of string you want to search for
- Color: Array of colors you want to search for
- Tol: Tolerance of the colors you will allow
- Step: How big you want to make the search squares.
50 = Default. 30-70 Recommended
- xs, ys, xe, ye: Bounds you want to search in

.. note::

by Starblaster100


Example:

.. code-block:: pascal

*)

Very basic but good to start off with.

Recursive

2012-05-16 03:05:00

Dam for a sec I thought you whipped that up that fast, then I noticed the blue writing.

Anyways, any idea of what the xe, ye, xs, ys mean? Also I used points for the cx cy as in Point(#1,#2), is that what it was asking for?

iBlank

2012-05-16 03:14:05

The xs,ys means x,y starting points and xe,ye means x,y ending points. So basically the top left corner and bottom right corner of what ever area you want to search in.

The cx,cy are the coordinates where that object is located if it is found. So if you were searching for an altar near the middle of the screen it would look like this:


FindObjEx(x, y, ['alt','tar','altar'], [232765,556749,997456], 5, 5, 180, 80, 340, 250)

Recursive

2012-05-16 03:34:27

Umm, after the 3rd comma, what is that you have in brackets? I feel that colour is supposed to be in there

iBlank

2012-05-16 03:47:35

You can have multiple colors in there. I was just using those as "example" colors.

Edit - I changed it to more "color like" numbers. Hopefully that helps.

P1nky

2012-05-16 04:04:12

Im going to give a example, hopefully you understand it.


FindColorTolerance(x,y,1713186, 184, 151, 334, 305, 1)
//FindColorTolerance(x,y, COLOR, X1, Y1 , X2 , Y2 , TOL)


the x1,y1,x2,y2 : that is where the coords are placed.
So if you put MSX1 MSY1 MSX2 MSY2 : that is the whole main screen.
To make it custom and restrict you must use the color picker and choose from one side(left top) to the the other side (bottom right). As a imaginary Box, although make sure not to accidentally have the coords interfering with the restricted area.

Hope you understood that, if it wasn't 3 am for me I would totally draw this all out to you on Paint… Lol.

iBlank

2012-05-16 04:13:49

From: P1nky
Im going to give a example, hopefully you understand it.


FindColorTolerance(x,y,1713186, 184, 151, 334, 305, 1)
//FindColorTolerance(x,y, COLOR, X1, Y1 , X2 , Y2 , TOL)


the x1,y1,x2,y2 : that is where the coords are placed.
So if you put MSX1 MSY1 MSX2 MSY2 : that is the whole main screen.
To make it custom and restrict you must use the color picker and choose from one side(left top) to the the other side (bottom right). As a imaginary Box, although make sure not to accidentally have the coords interfering with the restricted area.

Hope you understood that, if it wasn't 3 am for me I would totally draw this all out to you on Paint… Lol.


I know how to use this function, and I'm not exactly sure what you meant by the part in bold haha :p

Abu

2012-05-16 11:53:39

From: alevere4
I know how to use this function, and I'm not exactly sure what you meant by the part in bold haha :p


Ok, look at the area you want to search in. Got it? Good.

Now imagine that area as a box, picture it in your mind. Now open Simba and select the Color Picker Tool, it looks like an eyedrop.

What you want to do now is go back to Runescape and click the top-left hand corner your imaginary box. Done it? Good. Write down the co-ordinates given within the brackets.

Now click the bottom-right hand corner of your imaginary box and note down the co-ordinates again.

So now you have two sets of co-ordinates, which means 4 numbers.

Replace xe and ye With the first two co-ordinates you got, then replace xs and ys with the second two co-ordinates you got.

It should now search for your colour within your imaginary box :)

Recursive

2012-05-16 12:50:33

You guys are really helpful, it's like there is always a help police patrolling this forum day and night. Thanks, I really understand now but I could have other questions so hang on guys while I try this

EDIT: If this is getting a bit repetitive, I apologise but after doing all I read, I put this into my code to see what happens:

FindObjEx(100, 228,['Ope', 'n Doo'],[3358795,33424846,3358796], 5, 5, 293, 140, 269, 74);
ClickMouse2(true);


And when I hit compile, I get this:
[Error] (819:13): Variable Expected at line 818
Compiling failed.


EDIT2: When Abu says "look at the area you want to search in", does he mean look on minimap or on the main screen?

EDIT3: Nvm about the compiling error, I guess I don't have to put in numbers for the cx, cy

And WOOT!, It worked! Thanks a lot guys! This is what I used:
FindObjEx(x,y,['Ope', 'n Doo'],[3358795,33424846,3358796], 5, 5, 269, 74,293, 140);
ClickMouse2(true);

Thank you guys soo much!

John

2012-05-17 05:50:25

Instead of using:
FindObjEx(x,y,['Ope', 'n Doo'],[3358795,33424846,3358796], 5, 5, 269, 74,293, 140);
ClickMouse2(true);
Use:
FindObjEx(x,y,['Ope', 'n Doo'],[3358795,33424846,3358796], 5, 5, MSX1, MSY1, MSX2, MSY2);
ClickMouse2(true);


Heres a list of globals if you need a bit more of an explanation.

{ const MMX1, MMY1, MMX2, MMY2;
Description: MiniMap Edge Points. }
const
MMX1 = 550;
MMY1 = 8;
MMX2 = 703;
MMY2 = 161;

{ const MMCX, MMCY;
Description: MiniMap Centre Point. }
const
MMCX = 627;
MMCY = 85;

{ const MSX1, MSY1, MSX2, MSY2;
Description: Main Screen EdgePoints. }
const
MSX1 = 4;
MSY1 = 4;
MSX2 = 515;
MSY2 = 337;

{ const MSCX, MSCY;
Description: Main Screen Centre Points. }
const
MSCX = 259;
MSCY = 170;

{ const MIX1, MIY1, MIX2, MIY2;
Description: Inventory EdgePoints. }
const
MIX1 = 547;
MIY1 = 202;
MIX2 = 737;
MIY2 = 466;

{ const MICX, MICY;
Description: Inventory Centre Points. }
const
MICX = 642;
MICY = 334;

{ const MCX1, MCY1, MCX2, MCY2;
Description: Chat Screen EdgePoints. }
const
MCX1 = 4;
MCY1 = 342;
MCX2 = 514;
MCY2 = 475;

{ const MCCX, MCCY;
Description: Chat Screen Centre Points. }
const
MCCX = 250;
MCCY = 401;

{ const MBX1, MBY1, MBX2, MBY2;
Description: BankScreen EdgePoints (where you click the items, does not include tabs). }
const
MBX1 = 26;
MBY1 = 84;
MBX2 = 480;
MBY2 = 292;

{ const DBX1, DBY1, DBX2, DBY2;
Description: Deposit box edgepoints (only where the item appear) }
const
DBX1 = 91;
DBY1 = 57;
DBX2 = 443;
DBY2 = 262;

I understand that you are searching a custom area of the screen this time around, but this is just for future knowledge.

Abu

2012-05-17 15:09:30

Don't listen to John, the function he told you to use will search the whole Main Screen and not just in the area you want it to.

However, in future you will want to search the whole area of something (MainScreen, Inventory etc..) so take into account what he's said :)

John

2012-05-17 19:44:45

From: John

I understand that you are searching a custom area of the screen this time around, but this is just for future knowledge.


From: abu_jwka
Don't listen to John, the function he told you to use will search the whole Main Screen and not just in the area you want it to.

However, in future you will want to search the whole area of something (MainScreen, Inventory etc..) so take into account what he's said :)


I realized what i said when i posted, but was to tired to change it :P