Results 1 to 7 of 7

Thread: Help with Simple Function.

  1. #1
    Join Date
    Nov 2009
    Location
    Seattle, WA
    Posts
    589
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Help with Simple Function.

    so im Practicing TPA's , so what better way to practice then to put them in action. Can you guys review this function I made, it does not work at all, it doesn't even move the mouse to the ATPA >.>, It just stays in one place, and then it stops after running for 5 seconds. Im gonna see if its a problem with the length etc... but most likely im missing something, maybe ( I mean Most-Likely ) You guys can identify my problem Sorry Im asking, im really trying to figure out the problem, its just really giving me headaches.
    SCAR Code:
    Function Mine_Ore : Boolean; // Mines the Ore until Inventory is Full :D.
    var
      TPA         : TPointArray;   // Used for Finding the Points and Mining them.
      ATPA        : T2DPointArray; // Array of TPA.
      X, Y        : Integer;       // Used for Storing Points.
      I, Z, A, H  : Integer;       // Misc, Variables.
    begin
      if not LoggedIn then Exit; // Standard Failsafe.
      X := MSCX;                 // MainScreenCenter X. Needed for Spiral Functions.
      Y := MSCY;                 // MainScreenCenter Y. Needed for Spiral Functions.
      ColorToleranceSpeed(2);    // Needed for Accurate Color Finding.
      SetColorSpeed2Modifiers(0.07, 0.43);  // Modified Luminance and Saturation.
      SetRun(True);              // Enables Running.
      MakeCompass(Random(360));  // Rotates Compass in a Random Direction.
      for I := 1 to 28 do        // Repeatedly Finds the Color of the rock, and then Mines the Rock.
      begin
        FindColorsSpiralTolerance(x, y, TPA, 3692065, MSX1, MSY1, MSX2, MSY2, 2); // Finds the Mineral Color and Stores its Points.
        ATPA := SplitTPAEx(TPA, 5, 5); // Each Point is Seperated in a box, 5x5 Pixels.
        A := High(ATPA)
        for H := 0 to A do
        begin
          MiddleTPAEx(ATPA[h], x, y);
          MMouse(x, y, 4, 4);
          if WaitUpText('ine', 1000) then
          repeat
            Wait(Random(1300));
            Mouse(x, y, 0, 0, True);
          until not WaitUpText('ine', 1000);
          if InvFull then
          begin
            Result := True
            Writeln('Inventory is Full, Function Complete');
            Exit;
          end;
        end;
      SetColorSpeed2Modifiers(0.2,0.2);
      ColorToleranceSpeed(1);
      end;
    end;

    I'm really thinking its one of my loops >.> Can you guys see the problem?
    Sorry, the quotes really messed up the Standards of my script(When i declare var), its nicely spaced, the quotes just made it look nasty.
    Last edited by Heavenguard; 12-13-2009 at 05:04 PM. Reason: Had to fix qoutes
    Don't Troll, Don't Fight, Just keep the Respect
    Status : Offline

    Feel free to re-make my scripts ;D
    Community Member

  2. #2
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Heavenguard View Post
    SCAR Code:
    SetColorSpeed2Modifiers(0.07, 0.43);  // Modified Luminance and Saturation.
    It's actually Hue and Saturation modifiers. And 0.07 is kinda low, try using 0.15 or so. I find higher values allow more tolerance, eventhough I'm not 100% familiar with colorspeedmodifiers. Try (0.20, 0.43)

    Quote Originally Posted by Heavenguard View Post
    SCAR Code:
    FindColorsSpiralTolerance(x, y, TPA, 3692065, MSX1, MSY1, MSX2, MSY2, 2)
    You are using very low tolerance I see. Try debugging it by adding this line after the FindColorsSpiralTolerance:
    SCAR Code:
    WriteLn('Pixels found: '+IntToStr(Length(TPA)));
    And if it tells you "Pixels found: 0" then your tolerance is too low. Even 10 tolerance doesn't necessarily cause misclicking.

  3. #3
    Join Date
    Nov 2009
    Location
    Seattle, WA
    Posts
    589
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    So your saying it automatically stops the function because the Length of the TPA is 0?
    Don't Troll, Don't Fight, Just keep the Respect
    Status : Offline

    Feel free to re-make my scripts ;D
    Community Member

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Add
    DebugATPA(ATPA,'') after the line ATPA := SplitTPAEx(TPA, 5, 5);
    To see a visual picture of your ATPA.
    If stuff is colored, those are your 'hits' if nothings colored, then it failed to find colors.

    Edit: Yea what your/marpis said is a possibility.
    If it finds no color then A := High(ATPA) would be 0?
    An then your loop would be for for H := 0 to A(0) do

    Edit: Nina'd you Naum!
    Last edited by YoHoJo; 12-13-2009 at 06:12 PM.

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    If you have nothing to split, what will the length of a for..to..do loop be :

    SCAR Code:
    ATPA := SplitTPAEx(TPA, 5, 5); // Each Point is Seperated in a box, 5x5 Pixels.
        A := High(ATPA)

    //If TPA is zero, ATPA is 0, Hence A is 0.


  6. #6
    Join Date
    Nov 2009
    Location
    Seattle, WA
    Posts
    589
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I see now, I think that For..To..Do loop should be changed, since I have a InvFull failsafe, that I := 1 to 28 would not be needed, which means i can replace that with a simple repeat..until loop. With the repeat..until loop, it would continue finding the colors instead of setting a limit with the For..To..Do loop, and thanks Marpis, i think the tolerance is a tad bit low, Ill try adjusting it, or I might just make a better AutoColor.

    At the Luminence thing xD, i say luminance as i dont know what Hue means >.>.
    Thanks all of you My family
    Last edited by Heavenguard; 12-13-2009 at 06:24 PM.
    Don't Troll, Don't Fight, Just keep the Respect
    Status : Offline

    Feel free to re-make my scripts ;D
    Community Member

  7. #7
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    No No. Its fine that way.

    You just need to make sure your COLOR FINDING always finds a color. So your "A := High(ATPA)" always returns a value.

    Use ACA, and test the colors you picked. Also save the ACA file so you can always/add delete more colors if something is messing up.

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
  •