Results 1 to 7 of 7

Thread: TPA FindTree help...

  1. #1
    Join Date
    Dec 2007
    Location
    Michigan, USA
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPA FindTree help...

    Ok, so can someone help me understand/fix my tpa find tree function? It just finds every color on the screen by moving the mouse to it and it auto logs before it is even done... can someone help me out here?
    SCAR Code:
    function Findtree:Boolean;
    var
      i, mx, my : Integer;
      c : TpointArray;
    begin
      FindColorsSpiralTolerance(MSCX, MSCY, c, TreeColor, MSX1, MSY1, MSX2, MSY2, 15);
      ReArrangeandShortenArray(c, 20);
      if length(c)>0 then
      begin
        for i := 0 to high(c) do
        begin
          MMouse(c[i].x, c[i].y, 1, 1)
          wait(500 + random(250));
          if isuptext(treename) and not(findent(x, y, true)) then
          begin
            GetMousePos(mx, my);
            Mouse(mx, my, 0, 0, true);
            anti;
            inc(Clicks);
            ReportVars[1] := ReportVars[1] + 1;
            fflag(0);
            ftwait(2);
            Result := True;
            Exit;
          end;
        end;
        Result := False
      end;
    end;
    Thanks in advanced
    ~MikeVSkater
    Kindof Inactive...

  2. #2
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mikevskater View Post
    Ok, so can someone help me understand/fix my tpa find tree function? It just finds every color on the screen by moving the mouse to it and it auto logs before it is even done... can someone help me out here?
    SCAR Code:
    function Findtree:Boolean;
    var
      i, mx, my : Integer;
      c : TpointArray;
    begin
      FindColorsSpiralTolerance(MSCX, MSCY, c, TreeColor, MSX1, MSY1, MSX2, MSY2, 15);
      ReArrangeandShortenArray(c, 20);
      if length(c)>0 then
      begin
        for i := 0 to high(c) do
        begin
          MMouse(c[i].x, c[i].y, 1, 1)
          wait(500 + random(250));
          if isuptext(treename) and not(findent(x, y, true)) then
          begin
            GetMousePos(mx, my);
            Mouse(mx, my, 0, 0, true);
            anti;
            inc(Clicks);
            ReportVars[1] := ReportVars[1] + 1;
            fflag(0);
            ftwait(2);
            Result := True;
            Exit;
          end;
        end;
        Result := False
      end;
    end;
    Thanks in advanced
    ~MikeVSkater
    Why don't you make some writelns so you can see where it stops working?

    Basic debugging...
    Verrekte Koekwous

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

    Default

    You can try lowering the wait time otherwise look into finding x,y co-ords that are near each other and moving to larger areas of the colours first. It's a bit hard to explain, but that's the main point of using FindColors so you can get multiple co-ords and compare them to find the most likely spot. Otherwise, you could try lowering your tolerance as well as the wait time. Also, you could try to sort them by colour and make it check the locations with the colour closest to your original tree colour first.
    Just a few ideas
    Edit: Mastaraymond - He said it works, just very slowly so it logs out before it finds a tree, so he's asking ways to speed it up.
    Edit2: Is your ent finder supposed to have the x,y in it or should it have c[i].x, c[i].y just to make sure?
    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.

  4. #4
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster05 View Post
    You can try lowering the wait time otherwise look into finding x,y co-ords that are near each other and moving to larger areas of the colours first. It's a bit hard to explain, but that's the main point of using FindColors so you can get multiple co-ords and compare them to find the most likely spot. Otherwise, you could try lowering your tolerance as well as the wait time. Also, you could try to sort them by colour and make it check the locations with the colour closest to your original tree colour first.
    Just a few ideas
    Edit: Mastaraymond - He said it works, just very slowly so it logs out before it finds a tree, so he's asking ways to speed it up.
    Edit2: Is your ent finder supposed to have the x,y in it or should it have c[i].x, c[i].y just to make sure?
    To my understanding he said that it breaks out before it ended, must be my mistake then..
    Verrekte Koekwous

  5. #5
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    I'm not sure if this is your problem but RearrangeAndShortenArray is supposed to be a function that returns the shortened array as another TPA. That is by calling the function by itself like you have done, it doesn't actually shorten the 'c' TPA but gives a result of a shorten array. Basically what I'm saying is that your 'c' TPA isn't getting shortened and SCAR will have to go through every single one of your points to check for the uptext.

    So to fix:

    1. Make another TPA variable and use that variable in your for to do loop:
    SCAR Code:
    function Findtree:Boolean;
    var
      i, mx, my : Integer;
      c, d : TpointArray;
    begin
      FindColorsSpiralTolerance(MSCX, MSCY, c, TreeColor, MSX1, MSY1, MSX2, MSY2, 15);
      d := ReArrangeandShortenArray(c, 20);
      if length(d)>0 then
      begin
        for i := 0 to high(d) do
        begin
          //blah blah...

    2. You can use RaASTPA which unlike RearrangeAndShortenArray is a procedure so you can directly shorten the array. I'm not sure if this works though. It didn't work when I last tried it several months ago.

  6. #6
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    RAaSTPA(c, 20) is faster then RearrangeAndShortenArray(c, 20)

  7. #7
    Join Date
    Dec 2007
    Location
    Michigan, USA
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the help guys, im not home so i cant try to fix it then test, but when i get home ill fix it up and post if it works, is there a way to just do like findObj with tpa's? instead of finding all the colors first then checking if its a tree one by one after it found the cords, then repeating the find then check?

    @Raymond It moves the mouse to every color on the screen then moves to like the inventory then to next color one by one, and it just auto logs because it takes forever...
    Edit:Thanks for the help guys, i got it to work, it was my findent() thing caus i had it set to x and y, not c[i].x/c[i].y.... Thanks for all the help though
    Kindof Inactive...

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. FindTree(TreeType : String; Tol : Integer): Boolean
    By Cazax in forum Research & Development Lounge
    Replies: 13
    Last Post: 04-07-2008, 09:01 PM
  2. Replies: 12
    Last Post: 01-07-2008, 01:59 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
  •