I've been having troubles using a function I've created and putting it into a procedure. Basically I want a procedure that If it finds the character in a certain area then it carries out the function I created.
My main problem I think is on the logical side. I know how to find the character I just can't seem to include the function in a procedure without causing an error or two. My function is both Boolean and involves integers (see below for example) and I just don't know how to integrate that into a procedure. Please help?
Simba Code:
function FindObstaclePipe(Var X, Y : Integer): Boolean;
var
TPA : TPointArray;
ATPA : T2DPointArray;
Retry, I, H : Integer;
Begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 0, MSX1, MSY1, MSX2, MSY2, 15);
ATPA := TPAtoATPA(TPA, 25);
If Length(ATPA) = 0 Then
Exit;
H := High(ATPA);
For I := 0 To H Do
Begin
repeat
inc(Retry);
MiddleTPAEx(ATPA[I], X, Y);
MMouse(X, Y, 3, 3);
Wait(50 + Random(50));
If IsUpText('queeze') Then
Begin
Writeln('Found Obstacle Pipe!');
GetMousePos(X, Y);
Mouse(x, y, 0, 0, 1);
Result := True;
Exit;
End;
until((Retry=10) or (Result=True));
End;
End;
Or, alternatively based off some good advice I was considering changing this into a TP function instead of a integer function in which case it would look like:
Simba Code:
function FindObstaclePipe(Var TP : TPoint): Boolean;
var
TPA : TPointArray;
i, x, y : Integer;
begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, PipeColor, MSX1, MSY1, MSX2, MSY2, 15);
If Length(TPA) = 0 Then
Exit;
for i := 0 To high(TPA) do
begin
MMouse(TPA[i].x, TPA[i].y, 3, 3);
Wait(50 + Random(50));
If WaitUpText('queeze', 200+Random(200)) Then
begin
Writeln('Found Obstacle Pipe!');
ClickMouse2(mouse_Left);
GetMousePos(x, y);
TP := Point(x, y);
Result := True;
Wait(5000+random(2000));
end;
end;
end;
Thank you in advance!