Ok so i wanted to make a search to find a colour (the ore colour small part) and then see if it is next to the rock colour and then compare that to other ore colours to check if it is right rock. However ive got confused and cannot trace my error so i am asking for help. Here is what im using and my debug.
Simba Code:
Program new;
{$I SRL/SRL/misc/SMART.SCAR}
{$I SRL/SRL.scar}
{$i srl/srl/misc/paintsmart.scar}

Type
  ColourSetting = record
    Colour,Toll,w,h :Integer;
    Hue,Sat         :Extended;
  End;

const
  SmartWorld = 15;
  Members = False;
  SignedClient = True;
  HighDetail = False;

Function SetColours(What:String):ColourSetting;
Begin
  Case Lowercase(What) Of

  'coal_ore':Begin
               Result.Colour := 1908254
               Result.Hue    := 4.17
               Result.sat    := 0.26
               Result.Toll   := 6
               Result.w      := 4;
               Result.h      := 4;
             End;

  'norm_rock':Begin
                Result.Colour := 8422525
                Result.Hue    := 0.13
                Result.sat    := 0.07
                Result.Toll   := 13
                Result.w      := 5
                Result.h      := 5
              End;

  'addy_ore' :Begin
                Result.Colour := 12380341
                Result.Hue    := 0.22
                Result.sat    := 3.08
                Result.Toll   := 12
                Result.w      := 4
                Result.h      := 4
              End;

  'mith_rock':Begin
                Result.Colour := 14779536
                Result.Hue    := 0.20
                Result.sat    := 2.67
                Result.Toll   := 13
                Result.w      := 4
                Result.h      := 4
              End;

  End;
End;



Function FindColour(Colour,Toll,w,h:Integer; Hue,Sat:Extended):TPointArrayArray;
Var
  x,y  :Integer;
  TPA  :TPointArray;
Begin
SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(Hue,Sat);

  If FindColorsSpiralTolerance(x,y,TPA,colour,MSX1,MSY1,MSX2,MSY2,Toll) Then
    Result := TPAtoATPAEx(TPA,w,h);

SetColorToleranceSpeed(1);
SetColorspeed2Modifiers(0.2,0.2);//Normal Colour???
End;

Function CompareColour(ATPA1,ATPA2:TPointArrayArray;FinalTPA:TPointArray):Boolean;
Var
  X,Y,A,B       :Integer;
  Point1,Point2 :TPoint;
Begin
  For X := High(ATPA1) Downto 0 Do
    For Y := High(ATPA2) Downto 0 Do
    Begin
      Point1 := MiddleTPA(ATPA1[X]);
      Point2 := MiddleTPA(ATPA2[Y]);
      A := (Point1.x - Point2.x);
      B := (Point1.y - Point2.y);
      If (4>A) Or (A>-4) Or (4>B) Or (B>-4) Then
      Begin
        FinalTPA := CombineTPA(ATPA1[X],ATPA2[Y]);
        Result := True
      End;
    End;
End;

Function FindOre(which:string):TPointArray;
Var
  Coal,Addy,Mith            :Boolean;
  CurrentColour             :ColourSetting;
  OreTPA,RubishTPA          :TPointArray;
  ATPA1,ATPA2,ATPA3,OreATPA :TPointArrayArray; //OreATPA Just a TPA with a diff name to work with Compare Colour
Begin

  Coal := False;
  Addy := False;
  Mith := False;

  Case which Of
  'coal_ore' : Begin
                 Coal := True
               End;
  'addy_ore' : Begin
                 Addy := True
               End;
  'mith_ore' : Begin
                 Mith := True
               End;
  End;

  CurrentColour := SetColours(which);    //Ore Colour
  ATPA1 := FindColour(CurrentColour.Colour,CurrentColour.Toll,CurrentColour.w,
                      CurrentColour.h,CurrentColour.Hue,CurrentColour.Sat);

  CurrentColour := SetColours('norm_rock'); //Normal rockk
  ATPA2 := FindColour(CurrentColour.Colour,CurrentColour.Toll,CurrentColour.w,
                      CurrentColour.h,CurrentColour.Hue,CurrentColour.Sat);

  If CompareColour(ATPA1,ATPA2,OreTPA) Then //Checks ore colour and normal rock colour
  Begin
    SMART_DrawDotsEx(False,OreTPA,clRed);
    oreATPA := TPAToATPAEx(oreTPA, 40, 40);

    If (Coal=False) Then
    Begin
      CurrentColour := SetColours('coal_ore'); //Bad Ore
      ATPA3 := FindColour(CurrentColour.Colour,CurrentColour.Toll,CurrentColour.w,
                          CurrentColour.h,CurrentColour.Hue,CurrentColour.Sat);
      If Not CompareColour(OreATPA,ATPA3,RubishTPA) Then //Compare a TPA which matches Ore colour and rock to other ore colours
      Begin
        If (Addy=False) Then
        Begin
          CurrentColour := SetColours('addy_ore'); //Bad Ore
          ATPA3 := FindColour(CurrentColour.Colour,CurrentColour.Toll,CurrentColour.w,
                              CurrentColour.h,CurrentColour.Hue,CurrentColour.Sat);
          If Not CompareColour(OreATPA,ATPA3,RubishTPA) Then //Compare a TPA which matches Ore colour and rock to other ore colours
          Begin
            If (Mith=False) Then
            Begin
              CurrentColour := SetColours('mith_ore'); //Bad Ore
              ATPA3 := FindColour(CurrentColour.Colour,CurrentColour.Toll,CurrentColour.w,
                                  CurrentColour.h,CurrentColour.Hue,CurrentColour.Sat);
              If Not CompareColour(OreATPA,ATPA3,RubishTPA) Then
              Begin
                writeln('Compared to all not ore"s and passed, now the result will be a good TPA i hope');
                Result := OreATPA[0]
              End Else Begin
                writeln('mith ore is found and is a bad colour :(');
              End;
            End;
          End Else Begin
            writeln(' Addy Bad Colour Found');
          End;
        End;
      End;
    End Else Begin
      writeln('Coal Bad Colour FOund');
    End;
  End;
End;

Procedure TestOre;
Var
  TPA : TPointArray;
  Timer :Integer;
Begin
  MarkTime(Timer);
  writeln('Marking time to time this function :p');
  TPA := FindOre('coal_ore');
  writeln('It took ' + IntToStr(TimeFromMark(Timer)) + ' to run FindOre Function');
  SMART_DrawDotsEx(True,TPA,clRed);
  Wait(10000);
End;

begin
  Smart_Server := SmartWorld;
  Smart_Members := Members;
  Smart_Signed := SignedClient;
  Smart_SuperDetail := HighDetail;
  SetupSRL;
  Wait(10000);
  writeln('3 secounds left still start');
  Wait(1000);
  writeln('2 secounds left still start');
  Wait(1000);
  writeln('1 secounds left still start');
  Wait(1000);
  TestOre;
end.
Code:
SRL Compiled in 78 msec
SMART Initialized.
Loaded: Server 15, Members: False, Signed: True, Super Detail: False.
3 secounds left still start
2 secounds left still start
1 secounds left still start
Marking time to time this function :p
Coal Bad Colour FOund
It took 1950 to run FindOre Function
So i belive the error is that is it using coal as a good colour then a bad colour

THanks for any help