lol here comes another one...
I'm trying to make a function that returns false until it opens a door. Since the door can be open or closed, if it is closed and it opens it, the function will return true. If the door is open and the function closes it, it returns false. The call is a while loop that goes until it is true, so no matter what, the door should get opened up before the script continues past the call to the function.
Anyways, the problem I am having is: It right clicks the door fine, but it keeps returning that the door wasn't there when the door is Open. When the door is closed, the script works perfectly. It's as if it cannot read the Close text in the right click menu. Also, if i switch close and open, close works and open doesn't...
Here's my code for the function:
SCAR Code:
function FindDoor() : boolean;
var
MyTPA : TPointArray;
x,y,i : Integer;
begin
writeln('Looking for door...');
writeln('Trying first color');
FindColorsSpiralTolerance(234,153,MyTPA, 3293259, 0, 20, 500, 330, 10);
if Length(MyTPA) = 0 then
begin
writeln('Trying second color');
FindColorsSpiralTolerance(234,153,MyTPA, 3754069, 0, 20, 500, 330, 10);
if Length(MyTPA)=0 then
begin
writeln('Trying thrid color');
FindColorsSpiralTolerance(234,153,MyTPA, 5532284, 0, 20, 500, 330, 10);
if Length(MyTPA)=0 then
begin
writeln('Trying fourth color');
FindColorsSpiralTolerance(234,153,MyTPA, 2963779, 0, 20, 500, 330, 10);
end;
end;
end;
writeln('Color found!');
for i:= 0 to High(MyTPA)do
begin
MMouse(MyTPA[i].x, MyTPA[i].y,3,3);
if(IsUpTextMultiCustom(['Church', 'door']))then
begin
GetMousePos(x,y);
Mouse(x,y,3,3,False);
if (ChooseOption('pen'))then
begin
writeln('The door was closed and I opened it...')
Result := True;
Exit;
end
else if(ChooseOption('lose'))then
begin
writeln('The door was open and I closed it...');
if FindDoor then
begin
Result := False;
Exit;
end;
end
else
begin
writeln('The door was not found!');
if FindDoor then
begin
Result := False;
Exit;
end;
end;
end;
Wait(350+random(350));
end;
end;
And the call to the function:
SCAR Code:
while not (FindDoor) do
begin
writeln('Trying again...');
end;
And the output:
Code:
The door was not found!
Trying again...
Looking for door...
Trying first color
Color found!
The door was not found!
Trying again...
Looking for door...
Trying first color
Color found!
The door was not found!
(And so on.....)
Thanks for all your help today guys!