SRL Archive - OSR Help

Loop inside of Loop...


ownedlikenoob

2010-02-15 13:15:58

first off, This script is for the private server CrisesX. All the script does is finds the plank, clicks it then waits till the game is over and you get 2 points. It's pretty simple.

Here is the problem I am getting… As you see here:

Begin
repeat
KeyDown(76);
Keyup(76);
wait(1000);
KeyDown(8);
wait(2000);
KeyUp(8)
until(findColor(x,y,Login,0,0,600,600));
end;

I'm basically telling it to just press the "L" key and delete it and repeat (So I don't log out)

BUT! I am also telling it that if it does Disconnect (and find login screen) then to break from tht loop it is in and exit to the full loop. It is a loop inside of a loop. I have tried using variables, using Exit; and Break; and they don't work. It just keeps pressing l and deleting it until it is out of Pest control. (It even repeats it on the Login screen.)

Here is the whole script:

program CrisesXPC;
{.include srl/srl.scar}

Const
Board = 6195110;
Login = 2564863;

var
x,y,i : integer;

Procedure Check;
Begin
If (FindColor(x,y,Login,0,0,515, 338)) then
begin
WriteLn('Not Logged in, Logging in');
Mouse(375, 257,0,0,true);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
Wait(500);
Typesend(''); //username
Wait(1000);
Mouse(376, 269,0,0,true);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
Wait(1000);
TypeSend('') //Pass here
Mouse(625, 215,0,0,true); //Login Button
Wait(5000);
end
else
end;

Procedure InPc;
Begin
repeat
KeyDown(76);
Keyup(76);
wait(1000);
KeyDown(8);
wait(2000);
KeyUp(8)
until(findColor(x,y,login,0,0,600,600));
end;

begin
SetupSRL;
i:= -2
Mouse(199, -35,0,0,True);
Wait(200);
Mouse(685, 482,0,0,true);
Wait(200);
Mouse(721, 260,0,0,True);
Check;
WriteLn('Logged in, Looking for boat');
Repeat
SymbolAccuracy := 0.5;
if (FindSymbol(x, y, 'magic shop')) then
begin
i := i + 2;
Writeln('Congrats you have ganed ' +IntToStr(i)+ ' points!');
If (FindColor(x,y,Board,0,0,515, 338)) then
Mouse(x,y,0,0,True);
WriteLn('Should be in boat')
Mouse(578, 182,0,0,True);
Mouse(589, 257,0,0,True);
Wait(30000);
Mouse(642, 187,0,0,true);
SymbolAccuracy := 0.8;
end else
InPc;
Until(False);
end.

Yes I know my standards suck but this is for my personal use only so I don't really care about standards as of now.


EDIT: Found the error, Look in my main loop, Check is not under repeat. It only checks for the login screen at the beginning of the script and that's it. So basically it will only log you in once. All I needed to do was move Check; under repeat.

Pretty noob mistake :) But Hey, I wrote this at 3am so There's bound to be mistakes.


SetupSRL;
i:= -2
Mouse(199, -35,0,0,True);
Wait(200);
Mouse(685, 482,0,0,true);
Wait(200);
Mouse(721, 260,0,0,True);
Check;
WriteLn('Logged in, Looking for boat');
Repeat
SymbolAccuracy := 0.5;
if (FindSymbol(x, y, 'magic shop')) then
begin
i := i + 2;
Writeln('Congrats you have ganed ' +IntToStr(i)+ ' points!');
If (FindColor(x,y,Board,0,0,515, 338)) then
Mouse(x,y,0,0,True);
WriteLn('Should be in boat')
Mouse(578, 182,0,0,True);
Mouse(589, 257,0,0,True);
Wait(30000);
Mouse(642, 187,0,0,true);
SymbolAccuracy := 0.8;
end else
InPc;
Until(False);
end.

Dynamite

2010-02-15 13:34:35

I know it doesn't really help but here:

program CrisesXPC;
{.include srl/srl.scar}

const
Board = 6195110;
Login = 2564863;

var
x, y, i: integer;

procedure Check;
begin
if (FindColor(x, y, Login, 0, 0, 515, 338)) then
begin
WriteLn('Not Logged in, Logging in');
Mouse(375, 257, 0, 0, true);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
Wait(500);
Typesend(''); //username
Wait(1000);
Mouse(376, 269, 0, 0, true);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
KeyUp(8);
KeyDown(8);
Wait(1000);
TypeSend('') //Pass here
Mouse(625, 215, 0, 0, true); //Login Button
Wait(5000);
end
else
end;

procedure InPc;
begin
repeat
KeyDown(76);
Keyup(76);
wait(1000);
KeyDown(8);
wait(2000);
KeyUp(8)
until (findColor(x, y, login, 0, 0, 600, 600));
end;

begin
SetupSRL;
i := -2
Mouse(199, -35, 0, 0, True);
Wait(200);
Mouse(685, 482, 0, 0, true);
Wait(200);
Mouse(721, 260, 0, 0, True);
Check;
WriteLn('Logged in, Looking for boat');
repeat
SymbolAccuracy := 0.5;
if (FindSymbol(x, y, 'magic shop')) then
begin
i := i + 2;
Writeln('Congrats you have ganed ' + IntToStr(i) + ' points!');
if (FindColor(x, y, Board, 0, 0, 515, 338)) then
Mouse(x, y, 0, 0, True);
WriteLn('Should be in boat')
Mouse(578, 182, 0, 0, True);
Mouse(589, 257, 0, 0, True);
Wait(30000);
Mouse(642, 187, 0, 0, true);
SymbolAccuracy := 0.8;
end else
InPc;
until (False);
end.

void_hatred

2010-02-15 18:40:42

sorry but that's darn ugly and inefficient code, a highly regarded programming principle is DRY; Don't Repeat Yourself.


program CrisesXPC;
{.include SRL/SRL.scar}

const
Board = 6195110;
Login = 2564863;

var
x, y, i: integer;

procedure KeyStuff(key, times: Integer);
var
i: Integer;
begin
for i := 1 to times do
begin
KeyDown(key);
KeyUp(key);
end;
end;

procedure Check;
begin
if (FindColor(x, y, Login, 0, 0, 515, 338)) then
begin
WriteLn('Not Logged in, Logging in');
Mouse(375, 257, 0, 0, true);
KeyStuff(8, 12);
Wait(500);
Typesend(''); //username
Wait(1000);
Mouse(376, 269, 0, 0, true);
KeyStuff(8, 12);
Wait(1000);
TypeSend('') //Pass here
Mouse(625, 215, 0, 0, true); //Login Button
Wait(5000);
end
else
end;

procedure InPc;
begin
repeat
KeyDown(76);
Keyup(76);
Wait(1000);
KeyDown(8);
Wait(2000);
KeyUp(8)
until (FindColor(x, y, login, 0, 0, 600, 600));
end;

begin
SetupSRL;
i := -2

Mouse(199, -35, 0, 0, True);
Wait(200);
Mouse(685, 482, 0, 0, true);
Wait(200);
Mouse(721, 260, 0, 0, True);
Check;
WriteLn('Logged in, Looking for boat');

repeat
SymbolAccuracy := 0.5;
if (FindSymbol(x, y, 'magic shop')) then
begin
i := i + 2;
Writeln('Congrats you have ganed ' + IntToStr(i) + ' points!');
if (FindColor(x, y, Board, 0, 0, 515, 338)) then
Mouse(x, y, 0, 0, true);
WriteLn('Should be in boat')
Mouse(578, 182, 0, 0, true);
Mouse(589, 257, 0, 0, true);
Wait(30000);
Mouse(642, 187, 0, 0, true);
SymbolAccuracy := 0.8;
end else
InPc;
until (false); // I wouldn't suggest infinite loop
end.

that's how I'd do it (just improving code (in my opinion))

void_hatred

jimthesoundman

2010-02-15 19:48:31

if (FindColor(x, y, Login, 0, 0, 515, 338)) then


So how can there be a constant for the login screen color? I though Jagex had made it so that the client shifts the colors ever so slightly whenever you run it. Is that not true?

Sex

2010-02-16 05:26:44

Not on the Login screen afaik.

Mr. Doctor

2010-02-16 07:03:31

Maybe it wasn't finding your colors?

procedure InPc;
begin
repeat
KeyDown(76);
Keyup(76);
wait(1000);
KeyDown(8);
wait(2000);
KeyUp(8)
until(RsReady)
end;

Try that and post back. That should (not saying that it will) work.

YoHoJo

2010-02-16 20:19:10

http://www.youtube.com/watch?v=qmz_Dfnca88

ownedlikenoob

2010-02-21 22:24:24

From: void_hatred
sorry but that's darn ugly and inefficient code, a highly regarded programming principle is DRY; Don't Repeat Yourself.


program CrisesXPC;
{.include SRL/SRL.scar}

const
Board = 6195110;
Login = 2564863;

var
x, y, i: integer;

procedure KeyStuff(key, times: Integer);
var
i: Integer;
begin
for i := 1 to times do
begin
KeyDown(key);
KeyUp(key);
end;
end;

procedure Check;
begin
if (FindColor(x, y, Login, 0, 0, 515, 338)) then
begin
WriteLn('Not Logged in, Logging in');
Mouse(375, 257, 0, 0, true);
KeyStuff(8, 12);
Wait(500);
Typesend(''); //username
Wait(1000);
Mouse(376, 269, 0, 0, true);
KeyStuff(8, 12);
Wait(1000);
TypeSend('') //Pass here
Mouse(625, 215, 0, 0, true); //Login Button
Wait(5000);
end
else
end;

procedure InPc;
begin
repeat
KeyDown(76);
Keyup(76);
Wait(1000);
KeyDown(8);
Wait(2000);
KeyUp(8)
until (FindColor(x, y, login, 0, 0, 600, 600));
end;

begin
SetupSRL;
i := -2

Mouse(199, -35, 0, 0, True);
Wait(200);
Mouse(685, 482, 0, 0, true);
Wait(200);
Mouse(721, 260, 0, 0, True);
Check;
WriteLn('Logged in, Looking for boat');

repeat
SymbolAccuracy := 0.5;
if (FindSymbol(x, y, 'magic shop')) then
begin
i := i + 2;
Writeln('Congrats you have ganed ' + IntToStr(i) + ' points!');
if (FindColor(x, y, Board, 0, 0, 515, 338)) then
Mouse(x, y, 0, 0, true);
WriteLn('Should be in boat')
Mouse(578, 182, 0, 0, true);
Mouse(589, 257, 0, 0, true);
Wait(30000);
Mouse(642, 187, 0, 0, true);
SymbolAccuracy := 0.8;
end else
InPc;
until (false); // I wouldn't suggest infinite loop
end.

that's how I'd do it (just improving code (in my opinion))

void_hatred


Like I said, Not intended for other people's use but my own. Also, This is for a private server. CrisesX btw.

ownedlikenoob

2010-02-21 22:25:35

From: jimthesoundman
So how can there be a constant for the login screen color? I though Jagex had made it so that the client shifts the colors ever so slightly whenever you run it. Is that not true?


This is for a private server, CrisesX

i luffs yeww

2010-02-21 22:29:08

From: ownedlikenoob
This is for a private server, CrisesX


First of all, please try to not double post. Second time I've seen you do it today.

Anyway, RuneScape's log in screen doesn't shift, either. SRL uses constant colors for RuneScape, and I don't know of any private servers that would do it.

turbobk

2010-02-21 23:59:07

Why couldn't you just do:

procedure Check;
begin
if not LoggedIn then //
begin
WriteLn('Not Logged in, Logging in');
Mouse(375, 257, 0, 0, true);
KeyStuff(8, 12);
Wait(500);
Typesend(''); //username
Wait(1000);
Mouse(376, 269, 0, 0, true);
KeyStuff(8, 12);
Wait(1000);
TypeSend('') //Pass here
Mouse(625, 215, 0, 0, true); //Login Button
Wait(5000);
end
else
end;

procedure InPc;
begin
repeat
KeyDown(76);
Keyup(76);
Wait(1000);
KeyDown(8);
Wait(2000);
KeyUp(8)
until not LoggedIn; //
end;

Or is the login screen different from the current RS login screen?
Sorry I don't use private servers so I wouldn't know.

ownedlikenoob

2010-02-22 15:46:25

From: turbobk
Why couldn't you just do:

procedure Check;
begin
if not LoggedIn then //
begin
WriteLn('Not Logged in, Logging in');
Mouse(375, 257, 0, 0, true);
KeyStuff(8, 12);
Wait(500);
Typesend(''); //username
Wait(1000);
Mouse(376, 269, 0, 0, true);
KeyStuff(8, 12);
Wait(1000);
TypeSend('') //Pass here
Mouse(625, 215, 0, 0, true); //Login Button
Wait(5000);
end
else
end;

procedure InPc;
begin
repeat
KeyDown(76);
Keyup(76);
Wait(1000);
KeyDown(8);
Wait(2000);
KeyUp(8)
until not LoggedIn; //
end;

Or is the login screen different from the current RS login screen?
Sorry I don't use private servers so I wouldn't know.


For some reason SendKey has always made me do that, So I was like alright and just went with it.