Results 1 to 10 of 10

Thread: Help on ATPA clicking

  1. #1
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default Help on ATPA clicking

    So I have gone through mayors help to try and look for colours create a TPA and then an ATPA but I can't seem to make it run the script keeps coming back as an error. Hopefully someone can help me out

    Simba Code:
    program TPAClicking;
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}

    procedure ClickClimbWall();
    var
      x, y: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));

      if length(TPA) < 1 then
        exit;

      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);

      for i := 0 to high(ATPA) do
      begin
      mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
      if isMouseOverText(['climb-over'], 500) then
      begin
        fastClick(MOUSE_LEFT);
        break;
      end;
    end;
    end;

    begin
      smartEnableDrawing := true;
      setupSRL();

      ClickClimbWall();
    end.

  2. #2
    Join Date
    Jun 2014
    Location
    Oklahoma
    Posts
    336
    Mentioned
    22 Post(s)
    Quoted
    231 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    the script keeps coming back as an error

    Its because your "i" variable that you use for the for loop is not declared.

    So to declare it,

    Simba Code:
    var
      x, y, i: integer; // <-- notice the i
      TPA: TPointArray;
      ATPA: T2DPointArray;

  3. #3
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default

    Thanks for the camel, I got it to work... and I tried implementing it into my script, but now I'm getting another error

    Simba Code:
    procedure ClimbOverLowWall();
    var
      LowWall: Tbox;
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));

      if length(TPA) < 1 then
        exit;

      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);

      for i := 0 to high(ATPA) do
      begin
      mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
      if isMouseOverText(['limb-over'], 500) then
      fastClick(MOUSE_LEFT);
      WriteLn('Climbing over Low Wall');
      wait(gaussRangeInt(4800,5200));
        else begin                                       //getting error here
        writeLn('Searching again');
        LowWall :=intTobox(245, 238, 257, 276);
        mouseBox(LowWall, MOUSE_MOVE);
        wait(200);
        if isMouseOverText(['limb-over Obstacle']) then
        fastClick(MOUSE_LEFT)
        WriteLn('Climbing over Low Wall');
        wait(gaussRangeInt(4800,5200));
          else begin
          writeLn('Could not find');
          terminateScript();
          end;
        end;
      end;
    end;

    This is the error I'm getting
    'Error: Found unexpected token "else", expected "End" at line 100
    Compiling failed.'

  4. #4
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    @nero_dante;
    Simba Code:
    procedure ClimbOverLowWall();
    var
      LowWall: Tbox;
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));
      if length(TPA) < 1 then
        exit;
      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);
      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['limb-over'], 500) then
        begin  {added begin here}
          fastClick(MOUSE_LEFT);
          WriteLn('Climbing over Low Wall');
          wait(gaussRangeInt(4800, 5200));
        end  {added end here}
        else
        begin
          writeLn('Searching again');
          LowWall := intTobox(245, 238, 257, 276);
          mouseBox(LowWall, MOUSE_MOVE);
          wait(200);
          if isMouseOverText(['limb-over Obstacle']) then
          begin {added begin here}
            fastClick(MOUSE_LEFT) WriteLn('Climbing over Low Wall');
            wait(gaussRangeInt(4800, 5200));
          end {added end here}
          else
          begin
            writeLn('Could not find');
            terminateScript();
          end;
        end;
      end;
    end;

  5. #5
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    Thanks for the camel, I got it to work... and I tried implementing it into my script, but now I'm getting another error

    Simba Code:
    procedure ClimbOverLowWall();
    var
      LowWall: Tbox;
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));

      if length(TPA) < 1 then
        exit;

      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);

      for i := 0 to high(ATPA) do
      begin
      mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
      if isMouseOverText(['limb-over'], 500) then
      fastClick(MOUSE_LEFT);
      WriteLn('Climbing over Low Wall');
      wait(gaussRangeInt(4800,5200));
        else begin                                       //getting error here
        writeLn('Searching again');
        LowWall :=intTobox(245, 238, 257, 276);
        mouseBox(LowWall, MOUSE_MOVE);
        wait(200);
        if isMouseOverText(['limb-over Obstacle']) then
        fastClick(MOUSE_LEFT)
        WriteLn('Climbing over Low Wall');
        wait(gaussRangeInt(4800,5200));
          else begin
          writeLn('Could not find');
          terminateScript();
          end;
        end;
      end;
    end;

    This is the error I'm getting
    'Error: Found unexpected token "else", expected "End" at line 100
    Compiling failed.'
    It's because you're using the if/else statement improperly.

    If/then will execute ONLY the line immediately below it if the statement is true. For example:

    Simba Code:
    if True then
      writeln('Look it''s true')
    else
      writeln('Look it''s false');

    But what you've got written is

    Simba Code:
    if True then
      writeln('It''s true');
      clickStuff();
      doOtherStuff();
    else
      writeln('It''s false');

    Simba doesn't know why you have an else because there's no if statement above it (that it sees). You also have to note that if you're doing an if/else statement, the line above the else should not have a semicolon. To do what you want, you need to put the code inside a begin/end.

    So your script should look like this: (Assuming I guessed where you were trying to go with this)

    Simba Code:
    procedure ClimbOverLowWall();
    var
      LowWall: Tbox;
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));

      if length(TPA) < 1 then
        exit;

      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);

      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['limb-over'], 500) then
        begin //Add begin here
          fastClick(MOUSE_LEFT);
          WriteLn('Climbing over Low Wall');
          wait(gaussRangeInt(4800,5200));
        end else //end goes here
        begin
          writeLn('Searching again');
          LowWall :=intTobox(245, 238, 257, 276);
          mouseBox(LowWall, MOUSE_MOVE);
          wait(200);
          if isMouseOverText(['limb-over Obstacle']) then
          begin  // another begin here
            fastClick(MOUSE_LEFT)
            WriteLn('Climbing over Low Wall');
            wait(gaussRangeInt(4800,5200));
          end else //another end here
          begin
            writeLn('Could not find');
            terminateScript();
          end;
        end;
      end;
    end;

    Also your standards are a little wonky which makes it harder for folks like me to read your code and notice what went wrong. I fixed them up for you in my code above.

    Edit: Damnit @hoodz; ninja'd me

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  6. #6
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default

    Oh thanks a lot @hoodz for what I need to and thanks @3Garrett3 for explaining why Also, sory for the messyness of the script. I'll try and keep it cleaner like you have done.


    Okay so I implemented the correct end else begin, and it runs in the script. But it will do all steps and I only want it to do each step if it fails. I put in what i mean in the code


    Simba Code:
    procedure ClimbOverLowWall();
    var
      LowWall: Tbox;
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));
      if length(TPA) < 1 then
        exit;
      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);
      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['limb-over'], 500) then
        begin
          fastClick(MOUSE_LEFT);
          WriteLn('Climbing over Low Wall');
          wait(gaussRangeInt(4800,5200));               //So It does this, but then it continues to do the next step
        end
        else
        begin
          writeLn('Searching again');                  //I only want it to do this step If the first step fails.
          LowWall :=intTobox(245, 238, 257, 276);
          mouseBox(LowWall, MOUSE_MOVE);
          wait(200);
          if isMouseOverText(['limb-over Obstacle']) then
          begin
            fastClick(MOUSE_LEFT);
            WriteLn('Climbing over Low Wall');
            wait(gaussRangeInt(4800,5200));
          end
          else
          begin
          writeLn('Could not find');                   //Same for here, only want it to do this step if it fails the first and then second step
          terminateScript();
          end;
        end;
      end;
    end;

  7. #7
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    Oh thanks a lot @hoodz for what I need to and thanks @3Garrett3 for explaining why Also, sory for the messyness of the script. I'll try and keep it cleaner like you have done.


    Okay so I implemented the correct end else begin, and it runs in the script. But it will do all steps and I only want it to do each step if it fails. I put in what i mean in the code


    Simba Code:
    procedure ClimbOverLowWall();
    var
      LowWall: Tbox;
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 12163981, mainScreen.getBounds(), 6, colorSetting(8, 0.10, 0.86));
      if length(TPA) < 1 then
        exit;
      ATPA := TPA.toATPA(50, 70);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);
      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['limb-over'], 500) then
        begin
          fastClick(MOUSE_LEFT);
          WriteLn('Climbing over Low Wall');
          wait(gaussRangeInt(4800,5200));               //So It does this, but then it continues to do the next step
          break;  // bonsai - now it will quit the for loop and be done
        end
        else
        begin
          writeLn('Searching again');                  //I only want it to do this step If the first step fails.
          LowWall :=intTobox(245, 238, 257, 276);
          mouseBox(LowWall, MOUSE_MOVE);
          wait(200);
          if isMouseOverText(['limb-over Obstacle']) then
          begin
            fastClick(MOUSE_LEFT);
            WriteLn('Climbing over Low Wall');
            wait(gaussRangeInt(4800,5200));
          end
          else
          begin
          writeLn('Could not find');                   //Same for here, only want it to do this step if it fails the first and then second step
          terminateScript();
          end;
        end;
      end;
    end;
    You have a for loop to run it multiple times against each found spot.

    The first time through the loop it's doing the mouse left, the second time it's falling into the else part.

    Notice how I added the 'break' in there. That will make it quit the current loop ('for i := ...'). So after it finds and clicks the spot it will stop looping.

  8. #8
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    You have a for loop to run it multiple times against each found spot.

    The first time through the loop it's doing the mouse left, the second time it's falling into the else part.

    Notice how I added the 'break' in there. That will make it quit the current loop ('for i := ...'). So after it finds and clicks the spot it will stop looping.
    okay cool, does that mean I have to add the break lower down as well, before the bot terminates the script?

  9. #9
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    okay cool, does that mean I have to add the break lower down as well, before the bot terminates the script?
    You should have a break if the second attempt is successful, in the same way bonsai did for the first attempt.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  10. #10
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    You should have a break if the second attempt is successful, in the same way bonsai did for the first attempt.
    okay cool, thanks

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
  •