I know you said you got it fixed, but I want to point out something else to you. This is very inefficient, and I don't know why you would choose to do it this way, but I will show you how to do it your way first.
SCAR Code:
function WalkToStart:boolean;
var x,y,c: integer;
begin
BDTMTol:=30 //This should be here, the for to do is completely pointless
BDTMArea:=1 //as I see it...
wait(100+random(200));
LoadBeginningDTM;
repeat
if (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
Result:=True;
if not (DTMRotated(Beginning,x,y,MMX1,MMY1,MMX2,MMY2)) Then
Result:=False;
If Result = True then
begin
Writeln('Found DTM at a tolerance of '+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea))
mouse(x,y,0,0,True);
c:= 0;
Exit;
end;
BDTMTol:=BDTMTol+10;
BDTMArea:=BDTMArea+1;
c:=c+1;
Writeln('I Should Say This 6 Times If I Cant Find my DTM');
wait(1000);
until (Result=True)or(c>5);
Writeln('Could not find dtm at a tolerance of '+IntToStr(BDTMTol)+ ' and an area of '+IntToStr(BDTMArea))
end;
Much less code. Also, in your function, you never defined 'z' as an integer.
This is how I would do it.
SCAR Code:
function WalkToStart:boolean;
var x,y,c: integer;
begin
BDTMTol:=30 //This should be here, the for to do is completely pointless
BDTMArea:=1 //as I see it...
wait(100+random(200));
LoadBeginningDTM;
repeat
case DTMRotated(beginning, x, y, MMX1, MMY1, MMX2, MMY2) of
True:Result :=True;
False:Result:=False;
end;
If Result then
begin
Writeln('Found DTM at a tolerance of '+IntToStr(BDTMTol)+ 'and an area of '+IntToStr(BDTMArea))
mouse(x,y,0,0,True);
FreeDTM(Beginning);
Exit;
end;
BDTMTol:=BDTMTol+10;
BDTMArea:=BDTMArea+1;
inc(c);
Writeln('I Should Say This 6 Times If I Cant Find my DTM');
wait(1000);
until (Result=True)or(c>5);
Writeln('Could not find dtm at a tolerance of '+IntToStr(BDTMTol)+ ' and an area of '+IntToStr(BDTMArea));
FreeDTM(Beginning);
end;
Even though I would not use a repeat until loop for finding a dtm.