SRL Archive - OSR Help

Need help with "Until" function


Yanhua

2011-12-16 20:45:06

Hey guys,

I've been making a simple DTM script that will identify Tuna in bank and the withdraw them until inventory is full.

I need a bit of help on what code to use for "Keep clicking until inventory is full"

Here is what I have so far.



program Tuna;

{$i SRL\SRL.scar}


Var
Tuna, X, Y: Integer;

begin

SetupSRL;

Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
writeln('Found Tuna, clicking on it.');
MMouse(X, Y, 5, 5);
Wait(10+random(10))
If isUptext('aw Tun') Then
Begin
Wait(10+Random(100));
Mouse(X, Y, 0, 0, True)
//Until(What to put in here?)
end;

FreeDTM(Tuna);
end.


Thanks

Kyle Undefined

2011-12-16 20:48:57


repeat
//code here
until(InvFull);

Yanhua

2011-12-16 20:51:42

From: Kyle Undefined

repeat
//code here
until(InvFull);


Thanks a lot Kyle :)

Exactly what I was looking for.

Yanhua

2011-12-16 20:55:34

Okay, here is what I have now. Another problem.

Right now it just spam clicks on the Tuna in the bank, which isn't really human like.

Is there a way to fix this and click less often or slower?


program Tuna;

{$i SRL\SRL.scar}


Var
Tuna, X, Y: Integer;

begin

SetupSRL;

Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin

MMouse(X, Y, 5, 5);
Wait(10+random(10))
If isUptext('aw tun') Then
repeat
writeln('Found Tuna, clicking on it.');
Mouse(X, Y, 0, 0, True);
Until(InvFull);
writeln('Inventory Full, stopping')
end;

FreeDTM(Tuna);
end.

Cheers.

Kyle Undefined

2011-12-16 20:59:23

Try this:


program Tuna;
{$i SRL\SRL.scar}

var
Tuna, X, Y: Integer;

begin
SetupSRL;

Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
MMouse(X, Y, 5, 5);
Wait(10+random(10))
If isUptext('aw tun') Then
begin
repeat
Wait(RandomRange(2500, 750));
writeln('Found Tuna, clicking on it.');
Mouse(X, Y, 0, 0, True);
Until(InvFull);
writeln('Inventory Full, stopping');
end;
end;

FreeDTM(Tuna);
end.

Yanhua

2011-12-16 21:02:05

From: Kyle Undefined
Try this:


program Tuna;
{$i SRL\SRL.scar}

var
Tuna, X, Y: Integer;

begin
SetupSRL;

Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
MMouse(X, Y, 5, 5);
Wait(10+random(10))
If isUptext('aw tun') Then
begin
repeat
Wait(RandomRange(2500, 750));
writeln('Found Tuna, clicking on it.');
Mouse(X, Y, 0, 0, True);
Until(InvFull);
writeln('Inventory Full, stopping');
end;
end;

FreeDTM(Tuna);
end.


Sweet, cheers :)

Didn't think of that, so simple lol.

Kyle Undefined

2011-12-16 21:04:16

Lol, no worries :)

Yanhua

2011-12-16 21:09:15

Now that's working good, is there a way to make it repeat the whole script over and over again?


program Tuna;
{$i SRL\SRL.scar}

var
Tuna, X, Y: Integer;

begin
SetupSRL;

Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
MMouse(X, Y, 5, 5);
Wait(10+random(10))
If isUptext('aw tun') Then
begin
repeat
Wait(RandomRange(700, 500));
writeln('Found Tuna, clicking on it.');
Mouse(X, Y, 0, 0, True);
Until(InvFull);
writeln('Inventory Full, stopping');
end;
If Invfull then
begin
DepositAll;
end;



end;

FreeDTM(Tuna);
end.


Kyle Undefined

2011-12-16 21:20:15

You can do something like this:


program Tuna;
{$i SRL\SRL.scar}

procedure Banking();
var
Tuna, x, y : Integer;
begin
Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if(FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2))then
begin
MMouse(X, Y, 5, 5);
Wait(10 + Random(10))
if(isUptext('aw tun'))then
begin
repeat
Wait(RandomRange(700, 500));
WriteLn('Found Tuna, clicking on it.');
Mouse(X, Y, 0, 0, True);
until(InvFull);
WriteLn('Inventory Full, stopping');
end;
if(Invfull)then
DepositAll;
FreeDTM(Tuna);
end;
end;

begin
SetupSRL;

repeat
Banking();
until(IsKeyDown(VK_F10));
end.

It will repeat the procedure until you press the F10 key :)

Yanhua

2011-12-16 21:23:28

From: Kyle Undefined
You can do something like this:


program Tuna;
{$i SRL\SRL.scar}

procedure Banking();
var
Tuna, x, y : Integer;
begin
Tuna := DTMFromString('mwQAAAHic42RgYOABYjYg5gNiMSAWB2JBIOZggABGIOYGYhYgZoKKcUPVi0AxJxD3d3ZCVeDDhAEjERgOAEHKAoY=');
if(FindDTM(Tuna, X, Y, MSX1, MSY1, MSX2, MSY2))then
begin
MMouse(X, Y, 5, 5);
Wait(10 + Random(10))
if(isUptext('aw tun'))then
begin
repeat
Wait(RandomRange(700, 500));
WriteLn('Found Tuna, clicking on it.');
Mouse(X, Y, 0, 0, True);
until(InvFull);
WriteLn('Inventory Full, stopping');
end;
if(Invfull)then
DepositAll;
FreeDTM(Tuna);
end;
end;

begin
SetupSRL;

repeat
Banking();
until(IsKeyDown(VK_F10));
end.

It will repeat the procedure until you press the F10 key :)


:) Excellent.

Markus

2011-12-17 13:44:09

Repeat loops can be nested like this, you don't have to create a new procedure (but for stuff like that it's good practice).

program NoICantbebotheredToActuallyTestThis;
var
i, j : integer;
begin
i := 0;
j := 0;
repeat
i := 0;
writeln('This is loop 1');
repeat
i := i + 1;
writeln('this is loop 2');
until (i = 5);
j := j + 1;
until (j = 5);
end.