The Claw
2007-09-25 11:09:37
well ive already gotten 2 exception errors, due to it searching outside the screen (i think thats why). so should we put in some failsafes to make sure that doesnt happen? like this
i put in the "if Gx - 20…" 's.
function GasFound(fx, fy : Integer) : Boolean;
var
Color : array [1..2] of integer;
CountData : array of Integer;
i, Gx, Gy, count, n, FindTimes : Integer;
begin
Color[1] := 8296866;
Color[2] := 8951705;
Gx := fx;
Gy := fy;
FindTimes := 3;
for i := 1 to 2 do
begin
if Gx - 30 < 0 then Gx := MSCX - 30;
if Gy - 30 < 0 then Gy := MSCY - 30;
if (FindColorSpiralTolerance(Gx, Gy, Color[i], fx - 30, fy - 30,
fx + 30, fy + 30, 20)) then
begin
SetArrayLength(CountData, FindTimes);
while (n < FindTimes) do
begin
if Gx - 20 < 0 then Gx := MSCX - 20;
if Gy - 20 < 0 then Gy := MSCY - 20;
CountData[n] := CountColorTolerance(Color[i], Gx - 20, Gy - 20, Gx + 20, Gy + 20, 20);
n := n + 1;
if (n = FindTimes) then Break; // No need to Wait(100) again...
Wait(100);
end;
BubbleSort(CountData);
Count := iAbs(CountData[Length(CountData)-1] - CountData[0]);
if (Count > 40) then
begin
Result := FindGas(gx, gy);
if (Result) then
Writeln('** Found Gas ** Pixel Count Change is [' + inttostr(Count) + ']' );
end;
Gx := fx;
Gy := fy;
end;
end;
end;i put in the "if Gx - 20…" 's.