View Full Version : Repeat Until.
Failure
12-03-2011, 09:13 AM
Hello there again, I've been reading some things about it, but I can't figure it out...
So what I want is, like this.
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, 100, 658, 186, 658, 186, 5) or (Time = 5);
End;
But it still keeps it in an infinite loop.
program New;
{$i SRL/SRL.scar}
var x,y:Integer;
var Time:Integer;
var StartTime:Integer;
begin
//Setups
SetupSRL;
StartTime:= GetSystemTime;
Time := (GetSystemTime-StartTime);
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, 100, 658, 186, 658, 186, 5) or (Time = 5);
End;
Could anyone help me out with this? Cause I want it, if it waited 'X Amount of seconds' it moves on.
YoHoJo
12-03-2011, 09:19 AM
var
X, Y, Time, StartTime, LoopBegin:Integer;
begin
//Setups
SetupSRL;
StartTime:= GetSystemTime;
Time := (GetSystemTime-StartTime);
Begin
MarkTime(LoopBegin);
Repeat
Wait(50);
Until FindColorTolerance(x, y, 100, 658, 186, 658, 186, 5) or (TimeFromMark(LoopBegin) > 5000);
End;
A bit confused by your begin/ends though.
At end you have one
Begin
End. (end with period as the final end)
And before that you just have a bunch of procedures and functions.
Whatever though I'll assume you know what you are doing and this is just a snippit or something.
Anyways, I used the functions MarkTime and TimeFromMark which one gets the time (acts as a timer) and the second one tells you how long it's been since you started the timer.
I set it to > 5000 (5 seconds) you can change that to anything you want.
Flight
12-03-2011, 09:21 AM
I always have the correct result break out of the loop rather than the loop going until the result. For some reason, unknown to me, I've had problems doing that.
Repeat
if Result then
break;
Wait(1);
Until(false)
Failure
12-03-2011, 09:26 AM
var
X, Y, Time, StartTime, LoopBegin:Integer;
begin
//Setups
SetupSRL;
StartTime:= GetSystemTime;
Time := (GetSystemTime-StartTime);
Begin
MarkTime(LoopBegin);
Repeat
Wait(50);
Until FindColorTolerance(x, y, 100, 658, 186, 658, 186, 5) or (TimeFromMark(LoopBegin) > 5000);
End;
A bit confused by your begin/ends though.
At end you have one
Begin
End. (end with period as the final end)
And before that you just have a bunch of procedures and functions.
Whatever though I'll assume you know what you are doing and this is just a snippit or something.
Anyways, I used the functions MarkTime and TimeFromMark which one gets the time (acts as a timer) and the second one tells you how long it's been since you started the timer.
I set it to > 5000 (5 seconds) you can change that to anything you want.
Ohh I didn't gave everything of the Script and I got the End. ha, however, I done it exactly like you and it doesn't seem to work... =/
YoHoJo
12-03-2011, 09:32 AM
Can you copy/paste the script, what exactly is wrong? What do you mean doesn't work.
Here it is nice and neat and compiling.
{$i SRL\SRL.scar}
var
X, Y, Time, StartTime:Integer;
Procedure LetsWaitForAColor;
Var
LoopBegin:Integer;
Begin
MarkTime(LoopBegin);
Repeat
Wait(50);
Until FindColorTolerance(x, y, 100, 658, 186, 658, 186, 5) or (TimeFromMark(LoopBegin) > 5000);
End;
Begin
StartTime:= GetSystemTime;
Time := (GetSystemTime-StartTime);
SetupSRL;
LetsWaitForAColor;
End.
Failure
12-03-2011, 09:34 AM
This is my whole Script, only made a login procedure lol.
program New;
{$i SRL/SRL.scar}
var x,y:Integer;
var Time, StartTime, LoopBegin:Integer;
const
LoginScreen = 11746;
function LoggedOut : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColorTolerance(x, y, LoginScreen, 656, 409, 748, 446, 2)
then result := true
end;
Procedure Login;
Begin
Repeat
//Clicking Play DeadlyPkers
WriteLn('We are not logged in, will do it!');
MMouse(381, 349, 0, 0);
Wait(100);
Mouse(381, 349, 0, 0, True);
Wait(50);
//Waiting till find other screen.
Begin
WriteLn('We clicked Play DeadlyPkers, waiting for Click Here To Play');
Repeat
Wait(50);
Until FindColorTolerance(x, y, 67157, 350, 354, 444, 381, 5)
WriteLn('We are at the second screen!');
End;
//We're at the second screen
WriteLn('Going to move and click mouse on Click Here To Play!');
MMouse(393, 349, 0, 0);
Wait(50);
Mouse(393, 349, 0, 0, True);
Wait(50);
//Waiting till fully logged in
Begin
WriteLn('Waiting until we fully logged in');
Repeat
Wait(50);
Until FindColorTolerance(x, y, 3887360, 699, 139, 715, 157, 5)
WriteLn('We are completly logged in!');
End;
//We're fully logged in now, setting camera + Brightness
//Moving to Options
WriteLn('Setting settings, going to Options Tab');
MMouse(655, 484, 0, 0);
Wait(50);
Mouse(655, 484, 0, 0, True);
Wait(50);
//We're at the Options setting Brightness
WriteLn('Setting our Brightness!');
MMouse(709, 232, 0, 0);
Wait(50);
Mouse(709, 232, 0, 0, True);
Wait(50);
//Setting Compass to North
WriteLn('Setting the Compass North.');
MMouse(542, 27, 0, 0);
Wait(50);
Mouse(542, 27, 0, 0, True);
Wait(50);
//Setting Camera Angle to highest up
WriteLn('Doing the Camera now.');
KeyDown(38);
Wait(1000);
KeyUp(38);
//Back to inventory
WriteLn('Done everything, back to inventory.');
KeyDown(112);
Wait(10);
KeyUp(112);
Wait(100);
Until FindColorTolerance(x, y, 2018299, 552, 208, 597, 245, 5) or
FindColorTolerance(x, y, 1550029, 552, 208, 597, 245, 5)
//Until we found coins at first inventory space
End;
begin
//Setups
SetupSRL;
StartTime:= GetSystemTime;
Time := (GetSystemTime-StartTime);
//Main loop
ClearDebug;
If(LoggedOut = True) then
Login;
Begin
Repeat
MarkTime(LoopBegin);
Wait(50);
Until FindColorTolerance(x, y, 6762317, 658, 186, 658, 186, 5) or (TimeFromMark(LoopBegin) >= 10000);
End;
end.
The problem is, it waits longer then 5 seconds...
YoHoJo
12-03-2011, 09:36 AM
Failure, you know a login procedure is already included into SRL....?
{$i SRL\SRL.scar}
procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];
with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Nick := ''; //Player nickname - 3-4 letters of Player username.
Active := True;
end;
end;
Begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
End.
^Not sure of that compiles, just an example.
Failure
12-03-2011, 09:37 AM
Failure, you know a login procedure is already included into SRL....?
{$i SRL\SRL.scar}
procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];
with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Nick := ''; //Player nickname - 3-4 letters of Player username.
Active := True;
end;
end;
Begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
End.
^Not sure of that compiles, just an example.
This is not real Runescape, it's a Private server since I'm training myself so I do not have to worry about randoms etc. So I had to make my own.
YoHoJo
12-03-2011, 09:56 AM
Oh okay. Sure SRLs login won't work for it? If it looks the same it might work.
Anyways.
You need to put MarkTime(LoopBegin); BEFORE the repeat silly! Otherwise you keep 'resetting/starting the stopwatch' each time the loop happens, so you will never reach 5 seconds! Look at post #5 of this thread, the marktime is before the repeat!
Failure
12-03-2011, 09:58 AM
Oh okay. Sure SRLs login won't work for it? If it looks the same it might work.
Anyways.
You need to put MarkTime(LoopBegin); BEFORE the repeat silly! Otherwise you keep 'resetting/starting the stopwatch' each time the loop happens, so you will never reach 5 seconds! Look at post #5 of this thread, the marktime is before the repeat!
Hahha yeah figured it out I was like heey that's diffrent most noobiest mistake ever! Thanks though will definitly help me out sorry for being such a pain :fp:
YoHoJo
12-03-2011, 10:00 AM
NP, not a pain you are learning and that's what this community is all about!
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.