SRL Archive - OSR Help

Repeat color until found?


bas

2012-04-07 21:33:18

Hello!

How can i make it wait with clicking the NPC until it see the NPC color?

  if (FindColor(x,y,LocationMaster,27,24,501,320)) then

begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));

Thanks!

wantonman

2012-04-07 21:38:59

most common question

add

repeat
untill



look up looping in tut section … uh yea


repeat

FindColor(x,y,LocationMaster,27,24,501,320)

until
true;


begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));
end.

bas

2012-04-07 21:39:30

Thanks <3

bas

2012-04-07 21:58:46

Hm.. still dont get it :S

So it gotta be:




begin
if (FindColor(x,y,LocationMaster,27,24,501,320)) then

repeat

FindColor(x,y,LocationMaster,27,24,501,320)

until
true;


begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));
end;

end.

Sex

2012-04-07 22:01:34

while not FindColor(x, y, LocationMaster, 27, 24, 501, 320) do
wait(30);
Mouse(x, y, 4, 4, mouse_Left);
Wait(RandomRange(1500, 1700));
Somethin' like that.

Oh, btw there is a WaitFindColor(Tolerance) function in Timing.simba I believe.

tehq

2012-04-07 22:02:47

From: kipjes bende
Hm.. still dont get it :S

So it gotta be:




begin
if (FindColor(x,y,LocationMaster,27,24,501,320)) then

repeat

FindColor(x,y,LocationMaster,27,24,501,320)

until
true;


begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));
end;

end.


Don't use ClickMouse. Use Mouse or ClickMouse2 instead :)

bas

2012-04-07 22:03:12

From: Sex
while not FindColor(x, y, LocationMaster, 27, 24, 501, 320) do
wait(30);
Mouse(x, y, 4, 4, mouse_Left);
Wait(RandomRange(1500, 1700));
Somethin' like that.

Oh, btw there is a WaitFindColor(Tolerance) function in Timing.simba I believe.


IDK if i can use, im doing this on a private server :)

Blumblebee

2012-04-07 22:05:11

From: kipjes bende
Hm.. still dont get it :S

So it gotta be:




begin
if (FindColor(x,y,LocationMaster,27,24,501,320)) then

repeat

FindColor(x,y,LocationMaster,27,24,501,320)

until
true;


begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));
end;

end.


Here would be a basic version of what you want, fill in your parameters where I've located. A tutorial is much more important for you though than someone writing this out for you. You need to understand it before you can replicate it.

function FindSomething(): Boolean;
var
T: Integer;
begin
T := GetSystemTime();
repeat
if FindColor({parameters}) then
begin
Result := True;
Break;
end;
if GetSystemTime()-T > 5000 then
Exit;
Wait(RandomRange(200, 500));
until Result = True;
end;

bas

2012-04-07 22:06:26

I understand it, but idk how to get it right.

wantonman

2012-04-07 22:06:46

its good to see "while not findcolor();"

because its simple to stick in some anti ban right after ;)

Sex

2012-04-07 22:09:29

From: kipjes bende
IDK if i can use, im doing this on a private server :)


You can still use it :).

bas

2012-04-07 22:10:26

It dont work:S

I have:

begin
if (FindColor(x,y,LocationMaster,27,24,501,320)) then

begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));

while not FindColor(x, y, LocationMaster, 27, 24, 501, 320) do
wait(5000);

end;
end.


It wont start (unless im at that color, then it click)

else it start and instant stops

Sex

2012-04-07 22:17:58

Well yeah, you have it in an if find color block, therefore it will not run unless the color is found at first, so your while loop doesn't run. It must be outside the block.

Edit: What about this? :p
function MyWaitColor(var x, y : integer; Color, Tol, IncWait, RandWait,  MaxWait : integer; Area : TBox; Antiban : procedure(); ChanceAntiban : integer) : boolean;
var
t : integer;
begin
t := GetSystemTime;
while not result and ((GetSystemTime - t) < MaxWait) do
begin
result := FindColorTolerance(x, y, Color, Area.x1, Area.y1, Area.x2, Area.y2, Tol);
if result then
break;
if (Random(101) < ChanceAntiBan) and (Antiban <> nil) then
begin
Antiban();
continue;
end;
Wait(IncWait + Random(RandWait));
end;
end;

bas

2012-04-07 22:34:32

This doesn't repeat till found if not found right??

Also how would i do that? :S (mind if u write me? :P)
Last part i need for my script.

begin
if (FindColor(x,y,LocationMaster,27,24,501,320)) then

begin

MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x,y,mouse_Left);
Wait(randomrange(1500,1700));

while not FindColor(x, y, LocationMaster, 27, 24, 501, 320) do
wait(5000);

end;
end.

Sex

2012-04-07 23:27:35

Something like this may work?
function MyWaitColor(var x, y : integer; Color, Tol, IncWait, RandWait,  MaxWait : integer; Area : TBox; Antiban : procedure(); ChanceAntiban : integer) : boolean;
var
t : integer;
begin
t := GetSystemTime;
while not result and ((GetSystemTime - t) < MaxWait) do
begin
result := FindColorTolerance(x, y, Color, Area.x1, Area.y1, Area.x2, Area.y2, Tol);
if result then
break;
if (Random(101) < ChanceAntiBan) and (Antiban <> nil) then
begin
Antiban();
continue;
end;
Wait(IncWait + Random(RandWait));
end;
end;

function MakeBox(a, b, c, d : integer) : TBox;
begin
with result do
begin
x1 := a;
y1 := b;
x2 := c;
y2 := d;
end;
end;

var
x, y : integer;

begin
repeat
if MyWaitColor(x, y, LocationMaster, 0, 200, 250, 1000, MakeBox(27, 24, 501, 320), nil, 30) then
begin
ClickMouse(x + RandomRange(-4, 4), y + RandomRange(-5, 5), mouse_Left);
wait(2500 + random(300));
end;
until(false);
end.

bas

2012-04-08 11:08:31

    if (Random(101) < ChanceAntiBan) and (Antiban <> nil) then
begin
Antiban();
continue;
end;

and:
 ClickMouse(x + RandomRange(-4, 4), y + RandomRange(-5, 5), mouse_Left); 


What the hell is this? :P

Abu

2012-04-08 11:19:54

Listen kipjes, you're not listening to anyone - remove the if then around your FindColor function and replace it with while do

Like this:

begin
while (FindColor(x,y,LocationMaster,27,24,501,320)) do
Wait(30);

begin
MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
Mouse(x, y, True);
Wait(randomrange(1500,1700));
end;
end.

m34tcode

2012-04-08 11:27:16

We all had our learning moments dude. Programming is an abstract concept, and can be hard to initially wrap your mind aorund.

bas

2012-04-08 11:40:41

From: abu_jwka
Listen kipjes, you're not listening to anyone - remove the if then around your FindColor function and replace it with while do

Like this:

begin
while (FindColor(x,y,LocationMaster,27,24,501,320)) do
Wait(30);

begin
MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
Mouse(x, y, True);
Wait(randomrange(1500,1700));
end;
end.


Im gonna try it:P

bas

2012-04-08 11:41:41

From: m34tcode
We all had our learning moments dude. Programming is an abstract concept, and can be hard to initially wrap your mind aorund.


Thanks for understanding :)

bas

2012-04-08 11:52:38


begin
while (FindColor(x,y,LocationMaster,27,24,501,320)) do
Wait(30);

begin
MoveMouse(x,y+random(0));
Wait(randomrange(500, 700));
ClickMouse(x, y,mouse_Left);
Wait(randomrange(1500,1700));


end;
end.

Doesnt work sir, it moves the mouse to left upper conor and wait a few secs then stop the script.

m34tcode

2012-04-08 16:12:40

the upper left corner is the default location for FindColor. and any other finder function at that. If your script fails to find something, the point returned will be 0,0 or -1,-1, at the top left of your screen.

Try a different color, or add tolerance =]

CTS tut here:
The Master CTS Tutorial