SRL Archive - OSR Help

Variable assignment problem


slushpuppy

2012-11-18 05:42:39

function findDTMCustom(x,y,DTM,x1,y1,x2,y2 : Integer) : Boolean;
var aFound : Extended;
Tmpx,Tmpy : Integer;
begin
Result := FindDTMRotated(DTM, Tmpx, Tmpy, x1,y1,x2,y2, -Pi, Pi, Pi/30, aFound);
x := tmpX;
y := tmpy;
writeln('found DTM' + inttostr(x));
end;
function followBirdArrow : Boolean;
var xP,y : Integer;
begin
Result := false;
if findDTMCustom(xP, y,birdArrowMMDTM, MMX1, MMY1, MMX2, MMY2) then
begin
writeln('found arrow' + inttostr(xP));
Mouse(xP,y,3,3,Mouse_left);
sleepWhileMoving;
Result := true;
end;
end;



Output:

Output //

found DTM624
found arrow0


:confused:

riwu

2012-11-18 05:50:20

From: slushpuppy
function findDTMCustom(x,y,DTM,x1,y1,x2,y2 : Integer) : Boolean;
var aFound : Extended;
Tmpx,Tmpy : Integer;
begin
Result := FindDTMRotated(DTM, Tmpx, Tmpy, x1,y1,x2,y2, -Pi, Pi, Pi/30, aFound);
x := tmpX;
y := tmpy;
writeln('found DTM' + inttostr(x));
end;
function followBirdArrow : Boolean;
var xP,y : Integer;
begin
Result := false;
if findDTMCustom(xP, y,birdArrowMMDTM, MMX1, MMY1, MMX2, MMY2) then
begin
writeln('found arrow' + inttostr(xP));
Mouse(xP,y,3,3,Mouse_left);
sleepWhileMoving;
Result := true;
end;
end;



Output:



:confused:

your x, y on findDTMCustom should be var parameters.
Also could just pass the var param from FindDTMRotated directly to your function var param.

function findDTMCustom(var x,y: Integer; DTM,x1,y1,x2,y2 : Integer) : Boolean;
var
aFound : Extended;
begin
Result := FindDTMRotated(DTM, x, y, x1,y1,x2,y2, -Pi, Pi, Pi/30, aFound);
writeln('found DTM' + inttostr(x));
end;

http://villavu.com/forum/showthread.php?t=90561

slushpuppy

2012-11-18 05:55:13

Thanks! Massive oversight on my part :duh: