Results 1 to 13 of 13

Thread: Need some help with this script (loop not right?)

  1. #1
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need some help with this script (loop not right?)

    Hello,

    Currently I'm making a WillowPowerChopper. I worked pretty good unless I changed some things. Everytime I start the script, It does the job: Searching for a log an chop it. But now when I start it, it keeps searching for the tree and keeps clicking.I think something is wrong with the loop, but I can't find out, Heres the script so you can see what it does:

    Simba Code:
    program WillowPowerChopper;
    {$DEFINE SMART}
    {$i SRL/srl.simba}
    {$i sps/sps.simba}

    Procedure DeclarePlayers;
    Begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    End;

    Var
     x, y: Integer;

    Function ChoppingWillows: Boolean;
      Var
        PBox: TBox;
      begin
        PBox := IntToBox(206, 92, 339, 208);
        Result := (AveragePixelShift(PBox, 200, 350) > 250);
      end;

    Function WillowColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.29, 0.90);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 3957842, MSX1, MSY1, MSX2, MSY2, 8);
      if (Length(arP) = 0) then
      begin
        Writeln('No Willows found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 4.87) and (X <= 12.91) and (Y >= 6.07) and (Y <= 16.27) and (Z >= 3.59) and (Z <= 10.23) then
        begin
          Result := arC[i];
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
        Writeln('Willow tree not found.');
    End;

    Procedure AntiBan;

    Begin
     Case Random(250) of

    10:Begin
       HoverSkill('Woodcutting', False);
       Wait(1000+Random(500));
       Mouse(659, 189, 0, 0, True);
     End;
     0..5:
         Begin
           HoverSkill('Random', False);
           Wait(500 + Random(500));
           Mouse(658, 190, 0, 0, True);
         End;
     0..5:
         Begin;
           Mouse(689, 188, 0, 0, True);
           Wait(1200 + Random(300));
           Mouse(660, 188, 0, 0, True);
         End;
     0..5:
         Begin;
           SleepAndMoveMouse(200 + Random(100));
         End;
     0..5:
         Begin;
         ExamineInv
         End;
      End;
    End;

    Procedure Chopping;

    Begin
      FindNormalRandoms;
      Writeln('Searching for Willows...');
      RandomMovement;
      MakeCompass('Random');

      If FindObjCustom(x, y, ['op', 'wn'], [WillowColor], 10) Then
      Begin
      Writeln('Willow founded.');
      Wait(300 + Random(100));
      Mouse( x, y, 2, 2, True);
      Writeln('Chopping.');

      if (ChoppingWillows) then
      Antiban;

      end;
      repeat
      AntiBan;
      Until(Not ChoppingWillows)
    End;

    Procedure DropLogs;
    Var I: integer;
    Begin
      for I:= 0 To 2 Do
      Begin
        Writeln('Dropping logs.')
        DropAll
      End;
    End;

    Begin
      SetUpSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
    Repeat
      Chopping;
      If (InvFull) then
      DropLogs;
    Until(False)
    End.

    The script will for now only work with the old Willow look.

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    1. update your willow color
    2. use a little more specific upText
    3.dont use a tol of 10, since its an autocolor, use 0 or 1. (in your findobjcustom)

  3. #3
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, thanks for the tips, but the I think the loop in Chopping is not good.

  4. #4
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    well from what i see, if you are using findobjcustom, then that loop is fine. and what do u mean by "keeps clicking"

  5. #5
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I fixed the 'keep clicking' problem. What I mean with it: The script will wait till you stop chopping the tree and will click on the tree again but my script keeps clicking on tree even when it's chopping. <--- Fixed. The problem now is: it drop logs when you chopped a willow.

    Script:

    Simba Code:
    program WillowPowerChopper;
    {$DEFINE SMART}
    {$i SRL/srl.simba}
    {$i sps/sps.simba}

    Procedure DeclarePlayers;
    Begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    End;

    Var
     x, y: Integer;

    Function ChoppingWillows: Boolean;
      Var
        PBox: TBox;
      begin
        PBox := IntToBox(206, 92, 339, 208);
        Result := (AveragePixelShift(PBox, 200, 350) > 250);
      end;

    Function WillowColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.29, 0.90);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 3957842, MSX1, MSY1, MSX2, MSY2, 8);
      if (Length(arP) = 0) then
      begin
        Writeln('No Willows found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 4.87) and (X <= 12.91) and (Y >= 6.07) and (Y <= 16.27) and (Z >= 3.59) and (Z <= 10.23) then
        begin
          Result := arC[i];
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
        Writeln('Willow tree not found.');
    End;

    Procedure AntiBan;

    Begin
     Case Random(250) of

     0..5:  Begin
           HoverSkill('Woodcutting', False);
           Wait(1000+Random(500));
           Mouse(659, 189, 0, 0, True);
         End;
     0..5:
         Begin
           HoverSkill('Random', False);
           Wait(500 + Random(500));
           Mouse(658, 190, 0, 0, True);
         End;
     0..5:
         Begin;
           Mouse(689, 188, 0, 0, True);
           Wait(1200 + Random(300));
           Mouse(660, 188, 0, 0, True);
         End;
     0..5:
         Begin;
           SleepAndMoveMouse(200 + Random(100));
         End;
     0..5:
         Begin;
         ExamineInv
         End;
      End;
    End;

    Procedure Chopping;

    Begin
      FindNormalRandoms;
      Writeln('Searching for Willows...');
      RandomMovement;
      MakeCompass('Random');
     Begin;
       If FindObjCustom(x, y, ['hop', 'own'], [WillowColor], 0) Then
       Writeln('Willow founded.');
       Mouse( x, y, 2, 2, True);
       Writeln('Chopping.');
       Repeat
       AntiBan;
       Until not (ChoppingWillows) or (InvFull)
     End;
    End;


    Procedure DropLogs;
    Var I: integer;
    Begin
      for I:= 0 To 2 Do
      Begin
        Writeln('Dropping logs.')
        DropAll
      End;
    End;

    Begin
      SetUpSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
    Repeat
      Chopping;
      AntiBan;
      If (InvFull) then
      DropLogs;
    Until(False)
    End.

  6. #6
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    well when i run it, the droppin procedure works fine, but the detecting of the willow barely works

  7. #7
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Have you tested it at the new or old willow trees?

  8. #8
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    only the new ones because i simply dont know where to find the old ones

  9. #9
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thats the problem. I haven't added the new ones yet.

  10. #10
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    ok well as far as i was able to test, the dropping procedure worked for me. ( i changed colors to help detect new trees)

  11. #11
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Weird because my script is dropping my inventory every time I chopped a willow tree down.

    Simba Code:
    program WillowPowerChopper;
    {$DEFINE SMART}
    {$i SRL/srl.simba}
    {$i sps/sps.simba}

    Procedure DeclarePlayers;
    Begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    End;

    Var
     x, y: Integer;

    Function ChoppingWillows: Boolean;
      Var
        PBox: TBox;
      begin
        PBox := IntToBox(206, 92, 339, 208);
        Result := (AveragePixelShift(PBox, 200, 350) > 250);
      end;

    Function WillowColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.29, 0.90);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 3957842 //ONLY CHANGE IF YOU HAVE PROBLEMS WITH FINDING A WILLOW!
      , MSX1, MSY1, MSX2, MSY2, 8);
      if (Length(arP) = 0) then
      begin
        Writeln('No Willows found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 4.87) and (X <= 12.91) and (Y >= 6.07) and (Y <= 16.27) and (Z >= 3.59) and (Z <= 10.23) then
        begin
          Result := arC[i];
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
        Writeln('Willow tree not found.');
    End;

    Procedure AntiBan;

    Begin
     Case Random(200) of

     0:  Begin
           HoverSkill('Woodcutting', False);
           Wait(1000+Random(500));
           Mouse(659, 189, 0, 0, True);
         End;
     1:
         Begin
           HoverSkill('Random', False);
           Wait(500 + Random(500));
           Mouse(658, 190, 0, 0, True);
         End;
     2:
         Begin;
           Mouse(689, 188, 0, 0, True);
           Wait(1200 + Random(300));
           Mouse(660, 188, 0, 0, True);
         End;
     3:
         Begin;
           SleepAndMoveMouse(200 + Random(100));
         End;
     4:
         Begin;
         ExamineInv
         End;
      End;
    End;

    Procedure Chopping;

    Begin
      FindNormalRandoms;
      Writeln('Searching for Willows...');
      RandomMovement;
      MakeCompass('Random');
      Begin;
       If FindObjCustom(x, y, ['hop', 'own'], [WillowColor], 0) Then
       Writeln('Willow founded.');
        Begin
          Mouse( x, y, 2, 2, True)
          Writeln('Chopping.');
        End;
      End;
          Repeat
          AntiBan;
          Until not (ChoppingWillows)
       End;



    Procedure DropLogs;
    Var I: integer;
    Begin
      for I:= 0 To 2 Do
      Begin
        Writeln('Dropping logs.')
        DropAll
      End;
    End;

    Begin
      SetUpSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
     Repeat
      Chopping;
      AntiBan;
      If (InvFull) then
      Begin
      DropLogs;
      End;
     Until(False)
    End.

  12. #12
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Drop problem fixed, solution: had to restart Simba due update.

  13. #13
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    that makes more sense. i was really confused on how u were gettin that bug. glad u got it solved

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
  •