Results 1 to 7 of 7

Thread: object finding

  1. #1
    Join Date
    Mar 2009
    Location
    Antaractica, Penguin Drive
    Posts
    140
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default object finding

    in my script im using tpas to try and find trees, and while it is finding them i think there is something wrong with the way i coded it because the mouse jumps to each object many many times and eventually (sometimes after a matter of minutes or sometimes never) actually clicks the object. i'll attach my procedure but I'd love to fix this because it's really pissing me off.. sorry about standards but this is kind of a quick and dirty script. btw i can't use uptext so that's why i have a dtm to figure out if its the right object. also i know findtree doesn't need to be a function, not sure why I made it one.

    Code:
    function ismagic: boolean;
    var
    updtm,x ,y : integer;
    begin
    
    updtm := DTMFromString('mlwAAAHicY2dgYIgH4kwgLgXiSiDuBOKpQDwXiIWAWAyIxYFYBIgFoWxRIGa6eYOB/e4tBs77Nxi4Hj0C8m8xMN++zcD79CkDP1AeF2bEg6EAANguEL0=');
    if FindDTM(updtm, x, y, 0, 0, 500, 500) then
    begin
    Result := True;
    end;
      freedtm(updtm);
    end;  
    
    function findtree: boolean;
    var x,y: integer;
    TPA: array of tpoint;
    atpa: t2dpointarray;
    i: integer;
    begin
    FindColorsSpiralTolerance(x,y, TPA,10672344, MSX1, MSY1, MSX2, MSY2, 15);
    begin
      ATPA := TPAtoATPAEx(TPA, 10, 30);
      SortATPASize(ATPA,True);
      for i:=0 to High(ATPA) do
      begin
      middletpaex(atpa[i], x,y);
      mmouse(x,y,1,1);
      if ismagic then
      begin
        Mouse(x, y,1,1,True);
        writeln('tree found and clicked');
        Result := true;
        break;
      end;
      end;
      end;
    end;       
    
    procedure choppinloop;
    var
    x,y:integer;
    begin
      findtree;
      repeat
      wait(100);
      checkbob;
      until not IsChopping or (fullinvy);
    end;
    
    MAIN LOOP
    
    repeat
    repeat
    choppinloop;
    until fullinvy
    if fullinvy then
    repeat
    droplogs;
    checkbob;
    until not ExistsItemz(1);
    if not fullinvy then
    begin
    choppinloop;
    end;
    until(IsFKeyDown(12));

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    put a wait after your mmouse() and before your ismagic (like 100-200ms) and see if that changes things

  3. #3
    Join Date
    Mar 2009
    Location
    Antaractica, Penguin Drive
    Posts
    140
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    unfortunately that seems to have slown down the jumping :P but i do notice it clicking the tree after less time has passed so i guess thats good!

  4. #4
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    perhaps try putting
    Simba Code:
    if WaitFunc(@ismagic,10,1500) then
    it sounds as though the mouse is moving on too fast before the UpText DTM has appeared.

    Everything else appears to be fine, the function looks good and your DTM has sufficient tolerance on all points.

  5. #5
    Join Date
    Mar 2009
    Location
    Antaractica, Penguin Drive
    Posts
    140
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    That kind of helped but i still have the same problem.. I have a feeling the problem has to do with the loop somehow but it looks fine to me.. I might just try rewriting the function.

  6. #6
    Join Date
    Mar 2009
    Location
    Antaractica, Penguin Drive
    Posts
    140
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    just a little update, i've confirmed that my ismagic function isn't 100% working. it returns false quite a lot even when the uptext is on the screen. does anyone have any ideas for an alternate method of verifying the object?

  7. #7
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    something along the lines of this -
    Simba Code:
    function PGetUpText: string;
    begin
      Result := rs_GetUpTextAt(x co-ord, y co-ord);
    end;

    I'll let you find the x and y co-ordinates yourself. Hope that helps

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
  •