Just a guess, but it's probably because your compare r_pixel_one to itself =/
Originally Posted by exert from ur code
Or Operator (||)
Oh ok, well how can i fix it then.
Compare it to the pixel you want to test. So your comparing the pixel your testing to tree or background. You don understand if you compare a r_pixel_one to itself it will always be greater then itself -20.
That's like saying 10 > 10 -20. It will be always true and accomplishes nothing. What you want is something like this:
(|x - y| <= 20)
see now if x is 20 and y is 40, 20 - 40 = -20, then we take the abs value and its 20, which is <= 20.
if both x & y are unsigned chars you don't even have to worry about abs value assuming you always subtract the smaller from the larger, otherwise you'll loop back around.
And might I ask what exactly your trying to do, because there's got to be an easier way...
That's like saying 10 > 10 -20. It will be always true and accomplishes nothing. What you want is something like this:
(|x - y| <= 20)
see now if x is 20 and y is 40, 20 - 40 = -20, then we take the abs value and its 20, which is <= 20.
if both x & y are unsigned chars you don't even have to worry about abs value assuming you always subtract the smaller from the larger, otherwise you'll loop back around.
And might I ask what exactly your trying to do, because there's got to be an easier way...
OMG, thanks so much why06, your post helped so much that i started cracking up at how stupid my logic was. It's so obvious now that you explained it. If i could thank you multiple times i would. Thanks.
I am working on a runescape bot and this new feature will detect if i am cutting wood from the yew tree or if i got pulled into some random event in which both colors will change dramatically. Once my bot detects that it is in a random event, it will text me and then it will close itself. I wish there was an easier and more reliable way than using colors because it's really unreliable but it will work in my situation i guess.
Can i also do it like this:
would that work or am i just doing the same thing?
I am working on a runescape bot and this new feature will detect if i am cutting wood from the yew tree or if i got pulled into some random event in which both colors will change dramatically. Once my bot detects that it is in a random event, it will text me and then it will close itself. I wish there was an easier and more reliable way than using colors because it's really unreliable but it will work in my situation i guess.
Can i also do it like this:
Code:
int r = r_pixel_one-20; // then do the if statement... RGB(r_pixel_one >= r .......and so on
np. happens to everyone, and myself plenty of times. It's often easier for others to see obvious things you might have missed, and then ur feel like a dumbass >_>, but life goes on...
Nope.
Once they are equal
The same problem comes up...
Can i also do it like this:
would that work or am i just doing the same thing?
Code:
int r = r_pixel_one; // then do the if statement... RGB(r_pixel_one >= r - 20.......and so on
Once they are equal
Code:
int r = r_pixel_one;
Code:
RGB(r_pixel_one >= r - 20
Oh ya huh, lol there's the stupidity again. How can I fix it, I m puzzled cuz I can't really put any number values because they are always different
Ya I see what u r saying idk y I just posted that, lol it's really late at night where I m as u can tell, lol. Do u have any suggestions on how to solve this problem. Btw thanks for being such a great help.
The only idea coming to my mind right now is this:
Sorry that I can't really test anything since I m on the itouch lol. Thanks so much for your help I know I say it a lot but your help really means a lot to me.
The only idea coming to my mind right now is this:
Code:
tree= RGB(r_pixel_one || r_pixel_one +1 || r_pixel_one+2 ... and so on)
No, doesn't work like that o_O
Ya I kinda figured it wouldn't be that easy. Any suggestions?
Well, the problem isn't that i don't know what to do with the number (value of r_pixel), the problem is that if i want to do something else i will press the numpad 1 and then it will detect the pixel which will be another number. The r pixel is usually about 5-6.
EDIT: WHOAAAAAA!!!!! i think i just made a breakthrough, can i do this:
Wouldn't this work?
EDIT: WHOAAAAAA!!!!! i think i just made a breakthrough, can i do this:
Code:
r_pixel_one = GetRValue(pixel2);
int r = GetRValue(pixel2);
COLORREF tree = RGB(r_pixel_one >= r -20...........and so on.);
Wouldn't this work?
HOW DO I DO THIS HD. My brain is going to explode. I am pretty sure you knew the answer from the beginning.
If you want to check if COLORREF pixel2 is between for example RGB(200, 150, 100) and RGB(225, 125, 200) you'd use the following code:
if it's not that what you're trying to do please rephrase it =3
Code:
char r = ((char*)pixel2)[0]; //or GetRValue(pixel2)
char g = ((char*)pixel2)[1]; //GetGValue(pixel2)
char b = ((char*)pixel2)[2]; //GetBValue(pixel2)
if( (r >= 200 && r <= 225) &&//Red is ok
(g <= 150 && g >= 125) &&//Green is ok
(b >= 100 && b <= 200) )//B is also ok
{
//all are ok
...more code here...
}
