SRL Archive - OSR Help

findColorTolerance, backwards.


xdarkshadowx

2012-04-30 00:36:10

I'm trying to search a box from the bottom to the top, how do I reverse findColorTolerance? I know there is the spiral function, but I need to go from bottom to top. Thanks.

handColor:= GetColor(320,580);
findColorTolerance(clickX, clickY, handColor,99,69,356,542, 10);
mouse(clickX, clickY, 3, 4, true);

euphemism

2012-04-30 00:42:03

You could use 'FindColorsTolerance' and sort the resulting TPA from the bottom-right corner of the screen.

Daniel

2012-04-30 00:59:26

Since euphemism refuses to go into further detail and provide an example, here is one:

const
Colour = 0;
Tol = 16;

var
TPA: TPointArray;

begin
if(FindColorsTolerance(TPA, Colour, MSX1, MSY1, MSX2, MSY2, Tol)) then
InvertTPA(TPA);
end.

Abu

2012-04-30 01:01:16

From: Daniel
Since euphemism refuses to go into further detail and provide an example, here is one:

const
Colour = 0;
Tol = 16;

var
TPA: TPointArray;

begin
if(FindColorsTolerance(TPA, Colour, MSX1, MSY1, MSX2, MSY2, Tol)) then
InvertTPA(TPA);
end.


But haven't you inverted the TPA after already searching for it? Meaning it searched from top to bottom rather than vice versa?

xdarkshadowx

2012-04-30 01:25:06

I don't quite understand, what does TPA do? is it the 'image' that we're scanning? and how will the bot know where to click if I don't get my x and y coords from the found color? or would I need 2 searches?


handColor:= GetColor(320,580);
if findColorTolerance(TPA, handColor,99,69,356,542, 10) then
begin
InvertTPA(TPA); // idk what to do after here.

mouse(clickX, clickY, 3, 4, true);
end.

euphemism

2012-04-30 01:42:49

From: abu_jwka
But haven't you inverted the TPA after already searching for it? Meaning it searched from top to bottom rather than vice versa?


The non-spiral color finding functions search left-to-right, top-to-bottom. So, after the search is finished, the TPA will contain the points where the color has been found, and it will be ordered left-to-right, top-to-bottom. Using 'InvertTPA' will invert it, meaning the TPA now is ordered right-to-left, bottom-to-top, and the first point in the TPA will be the one xdarkshadowx wants.

From: xdarkshadowx
I don't quite understand, what does TPA do? is it the 'image' that we're scanning? and how will the bot know where to click if I don't get my x and y coords from the found color? or would I need 2 searches?


Go to the 'Tutorial Island' section of our forums and look up some tutorials on TPAs, which is an acronym for TPoint Array.

Edit: Tutorial that contains a good bit of relevant material

Daniel

2012-04-30 01:43:15

From: xdarkshadowx
I don't quite understand, what does TPA do? is it the 'image' that we're scanning? and how will the bot know where to click if I don't get my x and y coords from the found color? or would I need 2 searches?


handColor:= GetColor(320,580);
if findColorTolerance(TPA, handColor,99,69,356,542, 10) then
begin
InvertTPA(TPA); // idk what to do after here.

mouse(clickX, clickY, 3, 4, true);
end.

FindColorTolerance searches the screen from the top-left position, and will stop once only one instance of that colour is found - you cannot change this. However, what you CAN do is use FindColorsTolerance to find ALL instances of that colour on the screen. Like FindColorTolerance, it searches from the top-left position. However, we can invert (make it go back to front [i.e. instead of top-left to bottom-right, we can switch it so it goes bottom-right to top-left]) the TPA.

TPA stands for TPointArray (or array of TPoint). If you were only searching for one colour, you would only need a x and a y variable (which is represents a point on your computer screen). However, since we're looking for the colour in multiple locations, we have to store all of these locations in an array, which means multiple values of the same time (multiple values, i.e. locations, of the same type, i.e. point [or TPoint]).

So, what you'd need is something like:

const
Colour = 0;
Tol = 16;

var
TPA: TPointArray;

begin
// Search the Runescape main screen for the colour 'Colour'.
if(FindColorsTolerance(TPA, Colour, MSX1, MSY1, MSX2, MSY2, Tol)) then
begin
InvertTPA(TPA); // Switch the TPA values around.

Mouse(TPA[0].x, TPA[0].y, 4, 4, mouse_Left); // Left click on the bottom-right most colour.
end;
end.

If you notice, I use TPA[0].x and TPA[0].y. Initially, without inverting the TPA, this would contain the position of the colour found in the top-left most position. Because it stores it in how it is found. Inverting this TPA will then give us the opposite result :)

Abu

2012-04-30 01:51:01

From: euphemism
The non-spiral color finding functions search left-to-right, top-to-bottom. So, after the search is finished, the TPA will contain the points where the color has been found, and it will be ordered left-to-right, top-to-bottom. Using 'InvertTPA' will invert it, meaning the TPA now is ordered right-to-left, bottom-to-top, and the first point in the TPA will be the one xdarkshadowx wants.


Ah okay, now I understand :)

Thanks.