Here is a door opener i wrote for one my scripts(ref1) but it should be enough to get the idea across. What it basically does is search for the color of the door within the 4 tiles it borders(2 when closed, 2 when opened), and then if the options are open, then the door is closed.. etc.
function OpenDoor(Which: String): Boolean;
var
a, b, c, d, x, y: Integer;
Colors: TIntegerArray;
TL, DR: TPoint;
TPA, TPA2: TPointArray;
ATPA : T2DPointArray;
begin
case Which of
'ned':
begin
Colors:= [2117479, 2184046];
TL:= TileToMSEx(Tile(3101, 3259), 0, 0, 0);
DR:= TileToMSEx(Tile(3102, 3257), 1, 1, 0);
end;
'aggie':
begin
Colors:= [2117479, 2184046];
TL:= TileToMSEx(Tile(3088, 3259), 0, 0, 0);
DR:= TileToMSEx(Tile(3089, 3257), 1, 1, 0);
end;
'prisonout':
begin
Colors:= [6716292, 6716292];
TL:= TileToMSEx(Tile(3128, 3248), 0, 0, 0);
DR:= TileToMSEx(Tile(3129, 3246), 1, 1, 0);
end;
'prisonin':
begin
Colors:= [4934735, 5789788];
TL:= TileToMSEx(Tile(3123, 3245), 0, 0, 0);
DR:= TileToMSEx(Tile(3124, 3243), 1, 1, 0);
end;
end;
while(a < 6) and (Result = False) do
begin
Result:= False;
while (Length(TPA) < 1) or ( b < 6) do
begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Colors[0], TL.x, TL.y, DR.x, DR.y, 15);
FindColorsSpiralTolerance(MSCX, MSCY, TPA2, Colors[1], TL.x, TL.y, DR.x, DR.y, 15);
TPA:= CombineTPA(TPA, TPA2);
Inc(b);
if Length(TPA) > 0 then
break;
end;
b:= 0;
ATPA := TPAtoATPA(TPA, 15);
c := High(ATPA);
for d:= 0 to c do
begin
MiddleTPAEx(ATPA[d], x, y);
Mouse(x, y, 0, 0, False);
if ChooseOptionMultiEx(['Open Door', 'Open Prison Door'], 'all', ClickLeft) then
begin
Result:= True;
break;
end else
if ChooseOptionMultiEx(['Close Door'], 'all', Nothing) then
begin
Result:= True;
break;
end;
end;
while (b < 6) and (CharacterMoving) do
begin
wait(300 + RandomRange(100, 150));
Inc(b);
end;
b:= 0;
if Result = True then
begin
wait(400 + RandomRange(120, 210));
break;
end;
Inc(a);
end;
end;