Results 1 to 7 of 7

Thread: TPA function

  1. #1
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPA function

    SCAR Code:
    Function FindObjects : Boolean;
    Var
      Bx, By : Integer;
      TPA : Array Of TPoint;
      ATPA : T2DPointArray;
      I : Integer;

    Begin
       FindColorsSpiralTolerance(Bx, By, TPA, SearchColor, MSX1, MSY1, MSX2, MSY2, 10)
        Begin
          ATPA := SplitTPA(TPA, 15);
            For I := 0 To High(ATPA) Do
             If MiddleTPAEX(ATPA[i], Bx, By) Then
              MMouse(Bx, By, 1, 1);
              Wait(500 + Random(500));
              If IsUpText(SearchText) Then
                Begin
                 Mouse(Bx, By, 1, 1, true);
                 Flag;
                 Result := True;
                end else
              Result := False;
              Exit;
         end;
    end;

    i am using this function to search the main screen for certain objects, lets say a tree.

    how can i get it to only go through the point until it finds a tree and not untill its gone through all of them?

    i got this procedure from a tutorial and have changed it a bit its.
    http://www.villavu.com/forum/showthread.php?t=32182

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    SCAR Code:
    Function FindObjects : Boolean;
    Var
      Bx, By : Integer;
      TPA : Array Of TPoint;
      ATPA : T2DPointArray;
      I : Integer;
    Begin
       if (FindColorsSpiralTolerance(Bx, By, TPA, SearchColor, MSX1, MSY1, MSX2, MSY2, 10)) then
      Begin
        ATPA := SplitTPA(TPA, 15);
        For I := 0 To High(ATPA) Do
          If MiddleTPAEX(ATPA[i], Bx, By) Then
          begin
            MMouse(Bx, By, 1, 1);
            Wait(500 + Random(500));
            If IsUpText(SearchText) Then
            Begin
              Mouse(Bx, By, 1, 1, true);
              Flag;
              Result := True;
              Exit;
            end else
            begin
              Result := False;
              Exit;
            end;
          end;
      end;
    end;

    Fixed up the standards a bit for you also.
    :-)

  3. #3
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ty so much.

    Edit: I see what you did, lol, would have never noticed.

    Now i am getting a Type mismatch in
    SCAR Code:
    if (FindColorsSpiralTolerance(Bx, By, TPA, SearchColor, MSX1, MSY1, MSX2, MSY2, 10)) then

    Edit: Fixed it, all that was need is to remove the if then and it work correctly

  4. #4
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    i have the same probelms with it aswell.....

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    SCAR Code:
    Function FindObjects : Boolean;
    Var
      Bx, By : Integer;
      TPA : Array Of TPoint;
      ATPA : T2DPointArray;
      I: Integer;
    Begin
      FindColorsSpiralTolerance(Bx, By, TPA, SearchColor, MSX1, MSY1, MSX2, MSY2, 10);
      if (Length(TPA) < 1) then
        Exit;
      ATPA := SplitTPA(TPA, 15);
      For I := 0 To High(ATPA) Do
        If MiddleTPAEX(ATPA[i], Bx, By) Then
        begin
          MMouse(Bx, By, 1, 1);
          Wait(500 + Random(500));
          If IsUpText(SearchText) Then
          Begin
            Mouse(Bx, By, 1, 1, true);
            Flag;
            Result := True;
            Exit;
          end else
          begin
            Result := False;
            Exit;
          end;
        end;
    end;

    That should work. I forgot FindColorsSpiralTolerance wasn't a function.
    :-)

  6. #6
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ty, but i noticed that and edit my post.

    thanks for your help

  7. #7
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    So bobzilla, how do you make it work and find the object? This is what i am trying to learn... So far the only thing i came up with is

    if (FindObjects) then
    begin
    Writeln('Whatnow?');
    end;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. Any function that does this?
    By shadowpwner in forum OSR Help
    Replies: 2
    Last Post: 08-14-2007, 03:15 AM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM

Posting Permissions

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