Results 1 to 5 of 5

Thread: Out of range error

  1. #1
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default Out of range error

    So, i's still fairly new to ATPA's and I get an out of range error sometimes of this snippet. Anyone have any idea? Please and thanks in advance!
    Simba Code:
    Procedure RedShifter;

    var

    Shifter1TPA, Shifter2TPA:TPointArray;

    ShifterATPA:T2DPointArray;

    ShifterBox:TBox;

    i:integer;

    MSCTP:Tpoint;

    begin

      MSCTP := Point(MSCX, MSCY);

      if findcolorstolerance(Shifter1TPA, 1781205, MSX1, MSY1, MSX2, MSY2, 5) then

      begin

        ShifterATPA := SplitTPAEx(Shifter1TPA, 30, 30);

          SortATPAFrom(ShifterATPA, MSCTP);

          for i := 0 to high(ShifterATPA) do

          begin

            ShifterBox := GetTPABounds(ShifterATPA[i]);

            if findcolorstolerance(Shifter2TPA, 4610426, Shifterbox.x1, Shifterbox.Y1, Shifterbox.X2, Shifterbox.Y2, 15) then

            begin

              mmouse(Shifter2TPA[i].x, Shifter2TPA[i].y,2,2);//OUT OF RANGE ON THIS LINE!

              if WaitUpText('ttack', 160) then

              begin

                clickmouse2(mouse_left);

                wait(RandomRange(1500,3900));

              end;

            end;

          end;

        end;

      end;

  2. #2
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Shifter2TPA[0].x,Shifter2TPA[0].y

    Or better yet, put it in another for to do loop like u did for your ATPA


    and u should check your TPA/ATPA Lengths after if findcolorstol.....

    if Length(A/TPA) < 1 then Exit ; // in case no colors are returned.
    This will also prevent out or range errors.


    also after :
    clickmouse2(mouse_left);
    wait(RandomRange(1500,3900));

    use Exit; or Break; or it will continue with the loop(unless it's your intention).


    EDIT: Try and fix your scripting standards like Le Jingle's style It's way easier to read!
    Last edited by Sjoe; 04-07-2013 at 05:07 AM.

    Creds to DannyRS for this wonderful sig!

  3. #3
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Sjoekeloe pretty much got it

    I'll reiterate what he said, with the addition of it being a code example:
    (look for code comments)

    Simba Code:
    procedure RedShifter();
    var
      i, MidX, MidY: Integer;
      Shifter1TPA, Shifter2TPA: TPointArray;
      ShifterATPA: T2DPointArray;
      ShifterBox: TBox;
    begin
      FindColorsTolerance(Shifter1TPA, 1781205, MSX1, MSY1, MSX2, MSY2, 5);
      if (Length(Shifter1TPA) < 1) then
        Exit;

      SplitTPAExWrap(Shifter1TPA, 30, 30, ShifterATPA);
      SortATPAFrom(ShifterATPA, Point(MSCX, MSCY));

      for i := 0 to high(ShifterATPA) do
      begin
        ShifterBox := GetTPABounds(ShifterATPA[i]);
        FindColorsTolerance(Shifter2TPA, 4610426, Shifterbox.x1, Shifterbox.Y1, Shifterbox.X2, Shifterbox.Y2, 15);
        if (Length(Shifter2TPA) < 1) then // Make sure we have another TPA to work with, before trying to go out of range ;)
          Continue;
        MiddleTPAEx(Shifter2TPA, MidX, MidY);
        MMouse(MidX, MidY, 2, 2); // Clicks the middle of the TPA, instead of the x1,y1
        if WaitUpText('ttack', 160) then
        begin
          ClickMouse2(Mouse_Left);
          Wait(RandomRange(1500, 3900));
          Break; // Stop when we've accomplished the goal for the procedure.
        end;
      end;
    end;

    Cheers,
    Lj

  4. #4
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Thanks to both of you so much, I really appreciate it! I'll learn these ATPA's eventually!

  5. #5
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    Thanks to both of you so much, I really appreciate it! I'll learn these ATPA's eventually!
    Seems like you're doing great already though!

    Creds to DannyRS for this wonderful sig!

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
  •