Results 1 to 5 of 5

Thread: ATPA Color Finding

  1. #1
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    456
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Unhappy ATPA Color Finding

    Hi, I'm having trouble to get this to work, when I debug it is finding the ATPA's. It doesn't seem to work from that point on. I've been trying to figure it out for ages, is there something I am missing?

    Code:
    program New;
      {.Include srl/srl.scar}
      {.Include srl/srl/Misc/Debug.scar}
    
    var
    x, y : Integer;
    
    function Chop_Tree : Boolean;
    var
      LW, CTS, I, C, H: Integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      Result := False;
      LW := 15; // For Debugging
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.06, 1.04);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2978660, MSX1, MSY1, MSX2, MSY2, 13);
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, LW, LW);
      WriteLn('1'); // For Debugging
      if Length(ATPA) = 0 then WriteLn('TP not found');
        Exit;
      // DebugATPA(ATPA, '');
      
      C := 0; // For Debugging
      H := High(ATPA);
      For I := 0 to H do
      begin
        MiddleTPAEx(ATPA[i], x, y);
        MMouse(x, y, 2, 2);
        WriteLn('2' + IntToStr(C)); // For Debugging
        C := C + 1; // For Debugging
        If(IsUpTextMultiCustom(['Yew', 'Ye', 'ew'])) then
        begin
          Result := True;
          GetMousePos(x, y);
          Break;
        end;
      end;
    end;
    
    
    // Yew colors : 1592641 4690563 3766379 3898735 1725510 3700331
    
    
    begin
      ActivateClient;
      Chop_Tree;
    end.

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Can you be a bit more accurate when you say it doesn't work anymore? You've got the debugging stuff in there, but haven't said what it outputs. If it's simply that it doesn't click on the tree after finding it, then it's because you haven't told it to (you get the mouse position but no Mouse()).

    That's the only thing that stands out as something that wouldn't work, so if it's not that, a bit more information would be nice
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    456
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Sorry,

    right, it just doesn't mmouse to the middle of the array boxes. The numbers are just so I know which parts of the script actually ran and only '1' features in the Debug box. However I know that the ATPA is being created because when I use:

    Code:
    DebugATPA(ATPA, '');
    the correct colours have been created into ATPA in the Debug window.

    I am actually using SmartColors now instead but I'd still like to know what was going wrong.

    Thanks

  4. #4
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    The problem was with
    SCAR Code:
    if Length(ATPA) = 0 then WriteLn('TP not found');
        Exit;

    I skipped over it before as I read quickly. You need to have a begin and end to run multiple lines, so the debugging you added broke it. Should have been
    SCAR Code:
    if Length(ATPA) = 0 then
      begin
        WriteLn('TP not found');
        Exit;
      end;
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  5. #5
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    456
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thank you mixster! Greatly appriciated.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •