SRL Archive - OSR Help

How do I make when else happens it repeats the if?


rsbots2013

2013-05-24 05:06:29

When I tried to make it work it fails me. Could someone please correct this so it works out good :)
thank you

program new;

//{.include srl/srl.scar}
{$I SRL/SRL.Simba}

var
LogBalance1, LogBalance2, LogBalance3, LogBalance4, LogBalance5, LogBalance6, LogBalance7, LogBalance8 : integer;


Procedure LoadColor;
begin

LogBalance1 := 605282;
LogBalance2 := 604509;
LogBalance3 := 605798;
LogBalance4 := 602190;
LogBalance5 := 606571;
LogBalance6 := 603480;
LogBalance7 := 603219;
LogBalance8 := 601162;


end;

procedure CrossLogBalance;

var
x, y : integer;
aFound : extended;

begin

if FindColorSpiralTolerance( x, y, LogBalance1, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance2, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance3, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance4, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance5, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance6, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance7, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance8, 180, 160, 327, 226, 1) then
begin
writeln('Found Log Balance');
Mouse( x, y, 1, 1, True);
end else
Writeln('Log Balance NOT found... Attempting to retry...');
Wait(1000);
CrossLogBalance;

end;

begin
LoadColor;
SetAngle(SRL_ANGLE_HIGH);
MouseSpeed:= 20;
MakeCompass('n');
CrossLogBalance;
end.

Chris!

2013-05-24 07:16:51

My guess is that you need a begin..end after the end else.

procedure CrossLogBalance;
var
x, y : integer;
aFound : extended;
begin
if FindColorSpiralTolerance( x, y, LogBalance1, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance2, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance3, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance4, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance5, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance6, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance7, 180, 160, 327, 226, 1) or
FindColorSpiralTolerance( x, y, LogBalance8, 180, 160, 327, 226, 1) then
begin
writeln('Found Log Balance');
Mouse( x, y, 1, 1, True);
end else
begin
Writeln('Log Balance NOT found... Attempting to retry...');
Wait(1000);
CrossLogBalance;
end;
end;

Remember, if there's more than one action after the else, it needs a begin. Same with if..then's.

rsbots2013

2013-05-24 12:55:41

Thank You very much. That did the trick.