Results 1 to 6 of 6

Thread: Script repeats step after it's finished clicking

  1. #1
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default Script repeats step after it's finished clicking

    I wanted my script to find a 1. find a color 2. move mouse to color 3. right click color 4. click option 5. go to next procedure. 6. I got if fails all over so if it fails it restarts procedure.

    Problem: it keeps restarting when it shouldn't and I don't understand why it's doing it.

    Simba Code:
    procedure LeavingBalancingLedgeRoomLadder;

    var
      x, y : integer;
      aFound : extended;

    begin
    MakeCompass('S');
    SetAngle(SRL_ANGLE_HIGH);
    Wait(1500);
    if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
    // If finds Ladder
        begin
          MoveMouse( x, y);
        end else
        begin
          WriteLn('Failed to Find Ladder');
          LeavingBalancingLedgeRoomLadder;
        end;
          if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
            begin
              WriteLn('Found Balancing Ladder');
              Mouse( x, y, 0, 0, False);
              Wait(1000);
            end else
            begin
              WriteLn('Failed to Find Ladder');
              LeavingBalancingLedgeRoomLadder;
            end;
              if WaitOptionMulti(['Clim', 'limb', 'b-d'], 600) then
                begin
                  WriteLn('Successfully Clicked on Ladder!');
                  Exit;
                end;
    end;

  2. #2
    Join Date
    Dec 2011
    Location
    U.S.A.
    Posts
    635
    Mentioned
    5 Post(s)
    Quoted
    249 Post(s)

    Default

    There aren't any repeats there I see... where is this in the mainloop? It is probably repeating in the mainloop..... BTW Do NOT USE MOVEMOUSE!!! It's so botlike! Use MMouse!

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

    Default

    Try using a label instead of calling the same procedure again within a procedure. (makes it repeat it)

    Simba Code:
    procedure LeavingBalancingLedgeRoomLadder;

    var
      x, y : integer;
      aFound : extended;

    label DoItAgain;  // Declaring our label, like a var.

    begin

      DoItAgain:   //Makes it jump to here again :)

    MakeCompass('S');
    SetAngle(SRL_ANGLE_HIGH);
    Wait(1500);
    if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
    // If finds Ladder
        begin
          MoveMouse( x, y);
        end else
        begin
          WriteLn('Failed to Find Ladder');
          goto DoItAgain; // Goes to DoItAgain:
        end;
          if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
            begin
              WriteLn('Found Balancing Ladder');
              Mouse( x, y, 0, 0, False);
              Wait(1000);
            end else
            begin
              WriteLn('Failed to Find Ladder');
              goto DoItAgain; // Goes to DoItAgain:
            end;
              if WaitOptionMulti(['Clim', 'limb', 'b-d'], 600) then
                begin
                  WriteLn('Successfully Clicked on Ladder!');
                  Exit;
                end;
    end;

    EDIT: didn't look at the way it was coded, pretty insufficient like Engage said.

    Better like this:

    Simba Code:
    function LeavingBalancingLedgeRoomLadder: Boolean;
    var
      x, y, attempts, TimeOut: integer;

    begin

      MakeCompass('S');
      SetAngle(SRL_ANGLE_HIGH);
      Wait(1300 + Random(600)); //Static waiting is bad hmmkay

      MarkTime(TimeOut); // starts a failse time-out

      repeat
      if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
      begin
        MMouse(x, y, 2, 2);
        if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
        begin
          WriteLn('Found Balancing Ladder');
          ClickMouse2(Mouse_right);
          Result := WaitOptionMulti(['Clim', 'limb', 'b-d'], 600);
          if Result then
          begin
            WriteLn('Successfully Clicked on Ladder!');
            Exit;
          end;
        end;
      end;
      until((TimeFromMark(TimeOut) >= 25000)) // if we haven't found it after 25 seconds we leave the loop

      if TimeFromMark(TimeOut) >= 25000 then  // shut down script if we did not find ladder
      begin
        Writeln('Did not find Ladder')
        TerminateScript;
      end;

    end;
    Last edited by Sjoe; 05-28-2013 at 11:59 PM.

    Creds to DannyRS for this wonderful sig!

  4. #4
    Join Date
    Apr 2013
    Location
    England
    Posts
    223
    Mentioned
    2 Post(s)
    Quoted
    106 Post(s)

    Default

    are your colors correct? because if it doesnt get a hit on colors or uptext it will go into an infinite loop ... probably best to get it to return true or false, and if false loop 5 times or something ... just a failsafe incase there is no ladder

  5. #5
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Sawyer View Post
    There aren't any repeats there I see... where is this in the mainloop? It is probably repeating in the mainloop..... BTW Do NOT USE MOVEMOUSE!!! It's so botlike! Use MMouse!
    Thank You Sawyer, I didn't know better. I have not replaced all my MoveMouse with MMouse. And I agree, much more human like

  6. #6
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    Try using a label instead of calling the same procedure again within a procedure. (makes it repeat it)

    Simba Code:
    procedure LeavingBalancingLedgeRoomLadder;

    var
      x, y : integer;
      aFound : extended;

    label DoItAgain;  // Declaring our label, like a var.

    begin

      DoItAgain:   //Makes it jump to here again :)

    MakeCompass('S');
    SetAngle(SRL_ANGLE_HIGH);
    Wait(1500);
    if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
    // If finds Ladder
        begin
          MoveMouse( x, y);
        end else
        begin
          WriteLn('Failed to Find Ladder');
          goto DoItAgain; // Goes to DoItAgain:
        end;
          if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
            begin
              WriteLn('Found Balancing Ladder');
              Mouse( x, y, 0, 0, False);
              Wait(1000);
            end else
            begin
              WriteLn('Failed to Find Ladder');
              goto DoItAgain; // Goes to DoItAgain:
            end;
              if WaitOptionMulti(['Clim', 'limb', 'b-d'], 600) then
                begin
                  WriteLn('Successfully Clicked on Ladder!');
                  Exit;
                end;
    end;

    EDIT: didn't look at the way it was coded, pretty insufficient like Engage said.

    Better like this:

    Simba Code:
    function LeavingBalancingLedgeRoomLadder: Boolean;
    var
      x, y, attempts, TimeOut: integer;

    begin

      MakeCompass('S');
      SetAngle(SRL_ANGLE_HIGH);
      Wait(1300 + Random(600)); //Static waiting is bad hmmkay

      MarkTime(TimeOut); // starts a failse time-out

      repeat
      if FindColorSpiralTolerance( x, y, LedgeLadder, 190, 87, 339, 185, 5) then
      begin
        MMouse(x, y, 2, 2);
        if WaitUptextMulti(['Clim', 'limb', 'dow'], 600) then
        begin
          WriteLn('Found Balancing Ladder');
          ClickMouse2(Mouse_right);
          Result := WaitOptionMulti(['Clim', 'limb', 'b-d'], 600);
          if Result then
          begin
            WriteLn('Successfully Clicked on Ladder!');
            Exit;
          end;
        end;
      end;
      until((TimeFromMark(TimeOut) >= 25000)) // if we haven't found it after 25 seconds we leave the loop

      if TimeFromMark(TimeOut) >= 25000 then  // shut down script if we did not find ladder
      begin
        Writeln('Did not find Ladder')
        TerminateScript;
      end;

    end;
    Thank you, your answer helped A LOT!

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
  •