Results 1 to 8 of 8

Thread: script repeating action too many times

  1. #1
    Join Date
    Jan 2011
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default script repeating action too many times

    The problem is after MineMith cant find the colors(BTW iw ill change to findobject instead of find color later) of the rock to mine it walks to the coal, but after not find the color it walks again and again until it does it no more than 8 times(thats why i have the # of wait so it wont try mining more rocks then there are) I want the script to only walk to coal once not several times & after walking the to mine the coal(i already have procedure ready for mining coal)
    BTW this isn't the entire script only the part im stuck on.

    Simba Code:
    procedure MineMith;
    var
      x, y : Integer;
    begin
      if not LoggedIn then Exit;
      if FindColorTolerance(x, y, 7425099, MSX1, MSY1, MSX2, MSY2, 10) then // If the color (7425099) is found, the coordinates of where it was found is stored in the variables (x, y).
        Mouse(x, y, 5, 5, True) // This moves and clicks the mouse to x, y; 4, 4 is the randomness on x, y
      else

      begin
        Wait(1000); // Remember 1000ms = 1s
        MakeCompass('n');
        Writeln('First FindColor failed, trying second...');
        if FindColorTolerance(x, y, 7819343, MSX1, MSY1, MSX2, MSY2, 10) then
          Mouse(x, y, 4, 2, True) // This moves AND left clicks the mouse with randomness 4, 4; 'True' = Left click; 'False' = Right click
        else

        begin
          Wait(2000);
          Writeln('Second FindColor failed, trying third...');
          if FindColorTolerance(x, y, 6505026, MSX1, MSY1, MSX2, MSY2, 15) then
            Mouse(x, y, 4, 4, True)
          else

          begin
            Wait(2000);
            Writeln('Third FindColor failed, trying forth...');
            if FindColorTolerance(x, y, 6636611, MSX1, MSY1, MSX2, MSY2, 15) then
              Mouse(x, y, 4, 4, True)
            else

            begin
              Wait(1560);
              WalkToCoal;
              Writeln('Forth FindColors failed, logging out');
              Writeln('walk to coal'); // This is pretty straight forward, it logs your player out
            end;
          end;
        end;
      end;
    end; // There are so many 'end's because each begin has to have an end, otherwise you will get an "Identifier expected..." error

    function InvyFulBankIt: Boolean;
    var
      x, y : Integer;
    begin
      if not LoggedIn then Exit;
      if (InvFull) then
      if FindObjCustom(x, y, ['eposit', 'ank'], [5791845, 6121068], 5) then//Notice how I used "[]".
      begin
        Writeln('Found deposit box!');
        Mouse(x, y, 56, 6, True);//MMouse and uptext check isn't needed becaue it's already built into FindObjCustom, understand?
        Result := True;//Returns true of the copper ore was clicked.
      end else
        //Find deposit box procedure

    end;


    procedure RepeatMineMith;
    var
      numberOfWaits: Integer;
    begin // Although 'repeat' acts like a 'begin', 'begin' is still needed here to signal the start of the procedure
      repeat
        Wait(10195);
        MineMith;
        Inc(numberOfWaits); // The Inc() command simply increases the var numberOfWaits by 1
        Writeln('We have mined ' + IntToStr(numberOfWaits) + ' times');
      until(InvFull) or (numberOfWaits = 8);
        Wait(1095 + random(400));
        InvyFulBankIt;
    end;

    begin
      ClearDebug;
      SetupSRL;
      DeclarePlayers; // Calls the procedure, you can't forget this!
      LoginPlayer; // You want your player to login, right?
      RepeatMineMith;
    end.

  2. #2
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, so I don't really understand your question but here is a nicer version of your MineMith procedure
    Simba Code:
    procedure MineMith;
    var
      x, y, i : Integer;
      Colors : TIntegerArray;
    begin
      Colors := [7425099, 7819343, 6505026, 6636611];
      if not LoggedIn then Exit;
      for i := 0 to Colors do
      begin
        if FindColorTolerance(x, y, i, MSX1, MSY1, MSX2, MSY2, 10) then // If the color (7425099) is found, the coordinates of where it was found is stored in the variables (x, y).
        Mouse(x, y, 5, 5, True) // This moves and clicks the mouse to x, y; 4, 4 is the randomness on x, y
      else
      begin
        Wait(1560);
        WalkToCoal;
        Writeln('Forth FindColors failed, logging out');
        Writeln('walk to coal'); // This is pretty straight forward, it logs your player out
      end;
      end;
    end;

    -Boom

  3. #3
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    This is your problem:
    Simba Code:
    or (numberOfWaits = 8);

  4. #4
    Join Date
    Jan 2011
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    once again i have been misunderstood.

    The red flag shows where the character is walking.
    In the first picture he is going from the left area to the right that is good exactly what i want.
    In the second picture he is attempting to go to the right area again even though he is there, he is doing that because he cannot find any mith rocks.
    the problem is he keeps trying to go to the right area many times.
    I need him to go to the area on the right only once.

  5. #5
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by mika View Post
    once again i have been misunderstood.

    The red flag shows where the character is walking.
    In the first picture he is going from the left area to the right that is good exactly what i want.
    In the second picture he is attempting to go to the right area again even though he is there, he is doing that because he cannot find any mith rocks.
    the problem is he keeps trying to go to the right area many times.
    I need him to go to the area on the right only once.
    After walking to the coal when the script cannot find any mithril ore, the procedure needs to exit the loop.

    Simba Code:
    procedure MineMith;
    var
      x, y : Integer;
    begin
      if not LoggedIn then Exit;
      if FindColorTolerance(x, y, 7425099, MSX1, MSY1, MSX2, MSY2, 10) then
        Mouse(x, y, 5, 5, True);
      else

      begin
        Wait(1000);
        MakeCompass('n');
        Writeln('First FindColor failed, trying second...');
        if FindColorTolerance(x, y, 7819343, MSX1, MSY1, MSX2, MSY2, 10) then
          Mouse(x, y, 4, 2, True);
        else

        begin
          Wait(2000);
          Writeln('Second FindColor failed, trying third...');
          if FindColorTolerance(x, y, 6505026, MSX1, MSY1, MSX2, MSY2, 15) then
            Mouse(x, y, 4, 4, True);
          else

          begin
            Wait(2000);
            Writeln('Third FindColor failed, trying forth...');
            if FindColorTolerance(x, y, 6636611, MSX1, MSY1, MSX2, MSY2, 15) then
              Mouse(x, y, 4, 4, True);
            else

            begin
              Wait(1560);
              WalkToCoal;
              Writeln('Forth FindColors failed, logging out');
              Writeln('walk to coal');
              Exit;//breaks out of the repeat - until statement in the main loop
            end;
          end;
        end;
      end;
    end;

  6. #6
    Join Date
    Jan 2011
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    the exit did not fix the problem

  7. #7
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Alright, post your WalkToCoal procedure then

  8. #8
    Join Date
    Jan 2011
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    walk to coal procedure

    Simba Code:
    function WalkToCoal: Boolean;
    begin
      If RadialWalkTolerance(7697271 , 65, 110, 73, 5, 5, 10) then // 10 is the tolerance
      begin
        Writeln('Walking to coal is working fine!');
        Exit;
      end else
        Writeln(' Walking to coal error finding road using backup method.)');
        begin
          Wait(2000 + Random(1100))
          Mouse(692,81,2,2,true);
          Writeln('Successfully completed backup walking.');
        end
       Writeln('Walked to coal!');
    end;

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
  •