SRL Archive - SRL Archives

FindIColor and FindIColorTol


timmyboy

2006-04-27 20:48:47

FindIColor finds a color in the inventory and then clicks it if the user wants it to.
FindIColorTol is the same thing except with a tolerance.

In 'color' put the color of the object, in 'click' put if you want it to click, true or false, and in 'left put if you want it to left click or right, true or false.

{*******************************************************************************
function FindIColor(var x, y : Integer; color: Integer; click, left: boolean) : Boolean;
By: Timmyboy
Description: Finds a color in the inventory and then clicks it if the user wants it to.
*******************************************************************************}
function FindIColor(var x, y : Integer; color: Integer; click, left: boolean) : Boolean;
begin
if (FindColor(x, y, color, MIX1, MIY1, MIX2, MIY2)) then
begin
if ((click)=true) then
begin
wait(250+random(500));
mouse(x,y,2,2,left);
end;
Result := True;
end;
end;

In 'color' put the color of the object,in 'tol' put the color tolerance, in 'click' put if you want it to click, true or false, and in 'left put if you want it to left click or right, true or false.

{*******************************************************************************
function FindIColorTol(var x, y : Integer; color, tol: Integer; click, left: boolean) : Boolean;
By: Timmyboy
Description: Finds a color in the inventory and then clicks it if the user wants it to.
*******************************************************************************}
function FindIColorTol(var x, y : Integer; color, tol : Integer; click, left: boolean) : Boolean;
begin
if (FindColorTolerance(x, y, color, MIX1, MIY1, MIX2, MIY2, tol)) then
begin
if ((click)=true) then
begin
wait(250+random(500));
mouse(x,y,2,2,left);
end;
Result := True;
end;
end;

driger1592

2006-04-27 21:26:29

Here's a little hint to help you out with your scripting. I hope you don't mind, since it's meant to help ;)
function FindIColorTol(var x, y : Integer; color, tol : Integer; click, left: boolean) : Boolean;
begin
if (FindColorTolerance(x, y, color, MIX1, MIY1, MIX2, MIY2, tol)) then
if ((click)=true) then
begin
wait(250+random(500));
mouse(x,y,2,2,left);
end;
Result := True;
end;
This way, it takes up less lines of code (and essentially does the same thing). Also, your script wouldn't have worked the first time. If you include that if..then for the click=false part, you'd need a begin after if (FindColorTolerance(x, y, color, MIX1, MIY1, MIX2, MIY2, tol)) then and an end after the end that goes with if ((click)=false) then. Otherwise, the first if..then only affected the if..then that had click=true in it ;)

Other than that, it was good. If you want I can fix up both of the functions. Otherwise I advise you to, as without fixing them, they won't work correctly.

timmyboy

2006-04-27 21:37:11

There, fixed both of them. Is it good or do they still not work properly?:p
I tried both of them, and they seem to work fine.

Btw, thanks for the help.

driger1592

2006-04-27 22:04:59

Well, since there's not that click=false thing, there's no need for the begin..end after the first if..then. That added begin..end doesn't hurt anything, though (it just makes it two lines longer). Other than that, it's looking great. If you want, and I would love to do it, I will help you understand the workings of if..then's over MSN. I see that would require you getting MSN Messenger, but it's a worthwhile download since many scripters use it ;)

Again, very nice work!

timmyboy

2006-04-27 22:17:36

Lol, don't worry, I know how if works :P
I just messed up on those two, was doing it after playing American Football:D I have MSN btw, if you want to add me anyways,
-removed, spam not wanted :p-

driger1592

2006-04-27 22:20:14

I added you on MSN. I'm too busy tonight now to even talk though :\

timmyboy

2006-10-23 08:52:50

Edited this a bit.