SRL Archive - OSR Help

Script repeats step after it's finished clicking


rsbots2013

2013-05-28 19:10:53

I wanted my script to find a 1. find a color 2. move mouse to color 3. right click color 4. click option 5. go to next procedure. 6. I got if fails all over so if it fails it restarts procedure.

Problem: it keeps restarting when it shouldn't and I don't understand why it's doing it.

procedure LeavingBalancingLedgeRoomLadder;

var
x, y : integer;
aFound : extended;

begin
MakeCompass('S');
SetAngle(SRL_ANGLE_HIGH);
Wait(1500);
if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
// If finds Ladder
begin
MoveMouse( x, y);
end else
begin
WriteLn('Failed to Find Ladder');
LeavingBalancingLedgeRoomLadder;
end;
if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
begin
WriteLn('Found Balancing Ladder');
Mouse( x, y, 0, 0, False);
Wait(1000);
end else
begin
WriteLn('Failed to Find Ladder');
LeavingBalancingLedgeRoomLadder;
end;
if WaitOptionMulti(['Clim', 'limb', 'b-d'], 600) then
begin
WriteLn('Successfully Clicked on Ladder!');
Exit;
end;
end;

Sawyer

2013-05-28 19:32:29

There aren't any repeats there I see… where is this in the mainloop? It is probably repeating in the mainloop….. BTW Do NOT USE MOVEMOUSE!!! It's so botlike! Use MMouse!

Sjoe

2013-05-28 19:40:24

Try using a label instead of calling the same procedure again within a procedure. (makes it repeat it)


procedure LeavingBalancingLedgeRoomLadder;

var
x, y : integer;
aFound : extended;

label DoItAgain; // Declaring our label, like a var.

begin

DoItAgain: //Makes it jump to here again :)

MakeCompass('S');
SetAngle(SRL_ANGLE_HIGH);
Wait(1500);
if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
// If finds Ladder
begin
MoveMouse( x, y);
end else
begin
WriteLn('Failed to Find Ladder');
goto DoItAgain; // Goes to DoItAgain:
end;
if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
begin
WriteLn('Found Balancing Ladder');
Mouse( x, y, 0, 0, False);
Wait(1000);
end else
begin
WriteLn('Failed to Find Ladder');
goto DoItAgain; // Goes to DoItAgain:
end;
if WaitOptionMulti(['Clim', 'limb', 'b-d'], 600) then
begin
WriteLn('Successfully Clicked on Ladder!');
Exit;
end;
end;

EDIT: didn't look at the way it was coded, pretty insufficient like Engage said.

Better like this:


function LeavingBalancingLedgeRoomLadder: Boolean;
var
x, y, attempts, TimeOut: integer;

begin

MakeCompass('S');
SetAngle(SRL_ANGLE_HIGH);
Wait(1300 + Random(600)); //Static waiting is bad hmmkay

MarkTime(TimeOut); // starts a failse time-out

repeat
if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
begin
MMouse(x, y, 2, 2);
if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
begin
WriteLn('Found Balancing Ladder');
ClickMouse2(Mouse_right);
Result := WaitOptionMulti(['Clim', 'limb', 'b-d'], 600);
if Result then
begin
WriteLn('Successfully Clicked on Ladder!');
Exit;
end;
end;
end;
until((TimeFromMark(TimeOut) >= 25000)) // if we haven't found it after 25 seconds we leave the loop

if TimeFromMark(TimeOut) >= 25000 then // shut down script if we did not find ladder
begin
Writeln('Did not find Ladder')
TerminateScript;
end;

end;

EngageTheRage

2013-05-28 19:42:43

are your colors correct? because if it doesnt get a hit on colors or uptext it will go into an infinite loop … probably best to get it to return true or false, and if false loop 5 times or something … just a failsafe incase there is no ladder

rsbots2013

2013-05-28 23:26:09

From: Sawyer
There aren't any repeats there I see… where is this in the mainloop? It is probably repeating in the mainloop….. BTW Do NOT USE MOVEMOUSE!!! It's so botlike! Use MMouse!


Thank You Sawyer, I didn't know better. I have not replaced all my MoveMouse with MMouse. And I agree, much more human like :)

rsbots2013

2013-05-28 23:27:49

From: Sjoe
Try using a label instead of calling the same procedure again within a procedure. (makes it repeat it)


procedure LeavingBalancingLedgeRoomLadder;

var
x, y : integer;
aFound : extended;

label DoItAgain; // Declaring our label, like a var.

begin

DoItAgain: //Makes it jump to here again :)

MakeCompass('S');
SetAngle(SRL_ANGLE_HIGH);
Wait(1500);
if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
// If finds Ladder
begin
MoveMouse( x, y);
end else
begin
WriteLn('Failed to Find Ladder');
goto DoItAgain; // Goes to DoItAgain:
end;
if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
begin
WriteLn('Found Balancing Ladder');
Mouse( x, y, 0, 0, False);
Wait(1000);
end else
begin
WriteLn('Failed to Find Ladder');
goto DoItAgain; // Goes to DoItAgain:
end;
if WaitOptionMulti(['Clim', 'limb', 'b-d'], 600) then
begin
WriteLn('Successfully Clicked on Ladder!');
Exit;
end;
end;

EDIT: didn't look at the way it was coded, pretty insufficient like Engage said.

Better like this:


function LeavingBalancingLedgeRoomLadder: Boolean;
var
x, y, attempts, TimeOut: integer;

begin

MakeCompass('S');
SetAngle(SRL_ANGLE_HIGH);
Wait(1300 + Random(600)); //Static waiting is bad hmmkay

MarkTime(TimeOut); // starts a failse time-out

repeat
if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
begin
MMouse(x, y, 2, 2);
if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
begin
WriteLn('Found Balancing Ladder');
ClickMouse2(Mouse_right);
Result := WaitOptionMulti(['Clim', 'limb', 'b-d'], 600);
if Result then
begin
WriteLn('Successfully Clicked on Ladder!');
Exit;
end;
end;
end;
until((TimeFromMark(TimeOut) >= 25000)) // if we haven't found it after 25 seconds we leave the loop

if TimeFromMark(TimeOut) >= 25000 then // shut down script if we did not find ladder
begin
Writeln('Did not find Ladder')
TerminateScript;
end;

end;


Thank you, your answer helped A LOT!