Results 1 to 16 of 16

Thread: Open to ALL suggestions!

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default Open to ALL suggestions!

    This has kept me occupied for about 4 hours now, and I've gotten no where, so I'm leaving it up to anyone who is willing to give me a suggestion.

    Problem:
    • Almost exactly the same procedure in two different scripts, one works, one doesn't.


    Script one:
    • Works beautify, couldn't ask for better, returns the following debug image, which is exactly what I want.:



    Script two:
    • Using the exact same Color/SpeedModifiers/Tolerance, and gives the following debug image, not even close to what I want.:



    Here are the two scripts:

    Script one:
    SCAR Code:
    function Cut_TreeCutDown: Boolean;
    var
      TPA : TPointArray;
    begin
      if not LoggedIn then Exit;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.18, 0.28);
      FindColorsTolerance(TPA, 4481105, TP.x - 20, TP.y - 20, TP.x + 20, TP.y + 20, 14);
      if(Length(TPA) < 10)then
      begin
        //Writeln('Length inside box: ' + IntToStr(Length(TPA)));
        Result := True;
      end;
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(1);
    end;

    procedure Cut_WhileChopping;
    var
      ClickTree, NCTime, LastCount : Integer;
    begin
      MarkTime(ClickTree);
      NCTime := 15000 + Random(10000);
      LastCount := InvCount;
      while(InvCount < 28)and LoggedIn do
      begin
        if Cut_TreeCutDown then Break;
        if(TimeFromMark(ClickTree) > NCTime)then
          if InvCount = LastCount then Break;
        Wait(80 + Random(5000));
        Lv_LevelUp;
        S_MyAntiBan;
        S_FindRandoms;
      end;
    end;

    procedure Cut_ChopTrees;
    var
      fx, fy, i, x, y : Integer;
      s : String;
      TPA : TPointArray;
      ATPA : T2DPointArray;
    begin
      if not LoggedIn then Exit;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.18, 0.28);
      repeat
        FindColorsSpiralTolerance(fx, fy, TPA, 4481105, MSX1, MSY1, MSX2, MSY2, 14);
        ATPA := SplitTPAEx(TPA, 5, 5);
        DebugATPA(ATPA, '');
        if Length(ATPA) = 0 then Exit;
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

        for i := 0 to High(ATPA) do
        begin
          Writeln('Length:' + IntToStr(Length(ATPA[i])));
          if(Length(ATPA[i]) < 30)then Continue;
          MiddleTPAEx(ATPA[i], fx, fy);
          Wait(30 + Random(20));
          MMouse(fx, fy, 4, 4);
          s := RS_GetUpText;
          if((Pos('hop', s) > 0) and (Pos('illow', s) > 0))then
          begin
            GetMousePos(x, y);
            Wait(80 + Random(100));
            Mouse(x, y, 0, 0, True);
            TP := IntToPoint(x, y);
            Cut_WhileChopping;
          end;
        end;
      until(InvFull or not LoggedIn);
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(1);
    end;

    Script two:
    SCAR Code:
    procedure Cut_TreeColors;
    var
      c : Integer;
    begin
      SetArrayLength(TreeColor, 4);
        TreeColor := [2450006, 3764069, 4481105, 4162165];
      case LowerCase(Players[CurrentPlayer].Strings[0]) of
        'tree': c := 0;
        'oak': c := 1;
        'willow': c := 2;
        'yew': c := 3;
      else
        begin
          Writeln('No tree specified, logging out.');
          Wait(80 + Random(100));
          Logout;
          Players[CurrentPlayer].Active := False;
          Exit;
        end;
      end;
    end;

    procedure Cut_ColorSpeeds;
    begin
      case Lowercase(Players[CurrentPlayer].Strings[0]) of
        'tree' : SetColorSpeed2Modifiers(0.05, 1.37);
        'oak' : SetColorSpeed2Modifiers(0.10, 1.63);
        'willow' : SetColorSpeed2Modifiers(0.18, 0.28);
                  {begin
                     ColorToleranceSpeed(3);
                     SetColorSpeed3Modifiers(1);
                   end;}

        'yew' : SetColorSpeed2Modifiers(0.01, 0.76);
      end;
    end;

    function Cut_ColorTolerance: Integer;
    begin
      case Lowercase(Players[CurrentPlayer].Strings[0]) of
        'tree' : Result := 6;
        'oak' : Result := 5;
        'willow' : Result := 14;
        'yew' : Result := 14;
      end;
    end;

    function Cut_TreeCutDown: Boolean;
    var
      TPA : TPointArray;
      c : Integer;
    begin
      if not LoggedIn then Exit;
      ColorToleranceSpeed(2);
      Cut_ColorSpeeds;
      FindColorsTolerance(TPA, TreeColor[c], TP.x - 20, TP.y - 20, TP.x + 20, TP.y + 20, Cut_ColorTolerance);
      if(Length(TPA) < 10)then
      begin
        //Writeln('Length inside box: ' + IntToStr(Length(TPA)));
        Result := True;
      end;
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(1);
    end;

    procedure Cut_WhileChopping;
    var
      ClickTree, NCTime, LastCount : Integer;
    begin
      MarkTime(ClickTree);
      NCTime := 15000 + Random(10000);
      LastCount := InvCount;
      while(InvCount < 28)and LoggedIn do
      begin
        if Cut_TreeCutDown then Break;
        if TimeFromMark(ClickTree) > NCTime then
          if InvCount = LastCount then Break;
        S_MyAntiBan;
        Wait(80 + Random(5000));
        S_LevelUp;
        S_FindRandoms;
      end;
    end;

    procedure Cut_ChopTrees;
    var
      fx, fy, i, x, y, c : Integer;
      s, t : String;
      TPA : TPointArray;
      ATPA : T2DPointArray;
    begin
      if not LoggedIn then Exit;
      RunEnergy(60);
      ColorToleranceSpeed(2);
      Cut_ColorSpeeds;
      repeat
        FindColorsSpiralTolerance(fx, fy, TPA, TreeColor[c], MSX1, MSY1, MSX2, MSY2, Cut_ColorTolerance);
        //Writeln('Tolerance is: ' + IntToStr(Cut_ColorTolerance) + '.');
        ATPA := SplitTPAEx(TPA, 5, 5);
        DebugATPA(ATPA, '');
        if Length(ATPA) = 0 then Exit;
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

        for i := 0 to High(ATPA) do
        begin
          Writeln('Length:' + IntToStr(Length(ATPA[i])));
          if(Length(ATPA[i]) < 30)then Continue;
          MiddleTPAEx(ATPA[i], fx, fy);
          Wait(30 + Random(20));
          MMouse(fx, fy, 4, 4);
          s := RS_GetUpText;
          t := Players[0].Strings[0];
          if((Pos('hop', s) > 0) and (Pos((Copy(t, 2, Length(t))), s) > 0))then
          begin
            GetMousePos(x, y);
            Wait(80 + Random(100));
            Mouse(x, y, 0, 0, True);
            TP := IntToPoint(x, y);
            Cut_WhileChopping;
          end;
        end;
      until(InvFull or not LoggedIn);
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(1);
    end;

    If you need to see the whole script of either, they are attached.

    What I have tried:
    • ColorSpeedTolerance(3);
    • Remaking CTS(2)/Color using ACA multiple times.


    Frankly, I don't know what else to try.

    Again, I'm open to ALL and any suggestions, don't be afraid to suggest, even if it's the simplest thing. I will <3 you forever if you can help me fix this.

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    C is declared locally in your Cut_TreeColors; and your cut procedure.

    Delete var c : integer from both and declare it globally.

  3. #3
    Join Date
    May 2007
    Location
    Some where fun.
    Posts
    2,891
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    C is declared locally in your Cut_TreeColors; and your cut procedure.

    Delete var c : integer from both and declare it globally.
    OR, it could mean that when you reloaded runescape , the colors changed.

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nope. What I said is why. It is searching for index 0 of TreeColors in the second script (which is not willows).

  5. #5
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    C In Cut_TreeColors would store the tree color and C in Cut_TreeDown has no value. If you do what Da 0wner said, delete the int C in Cut_TreeDown and the int C in Cut_TreeColors and make C a global int that way the int C in Cut_TreeDown would have a color to find.

  6. #6
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try this:
    SCAR Code:
    function Cut_TreeColor : integer;
    var
      TreeColor : TIntegerArray;
    begin
        TreeColor := [2450006, 3764069, 4481105, 4162165];
        InStrArrEx(Lowercase(Players[CurrentPlayer].Strings[0]), ['tree', 'oak', 'willow', 'yew'], result);
        result := TreeColor[result];
        result := result * (Integer((Lowercase(Players[CurrentPlayer].Strings[0]) = 'tree') xor (result > 2450007)));
        if result <> 0 then
          exit;
        Writeln('No tree specified, logging out.');
        Wait(80 + Random(100));
        Logout;
        Players[CurrentPlayer].Active := False;
    end;

    Returns the color you need to search for .
    Last edited by Da 0wner; 07-07-2009 at 11:15 AM.

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    C is declared locally in your Cut_TreeColors; and your cut procedure.

    Delete var c : integer from both and declare it globally.
    I love you!

    Works like a charm, I can't believe something that simple caused me all that grief.

    Also, Da 0wner, what you suggested gives me a Runtime error when it tries to find the color.

    Quote Originally Posted by TRiLeZ View Post
    C In Cut_TreeColors would store the tree color and C in Cut_TreeDown has no value. If you do what Da 0wner said, delete the int C in Cut_TreeDown and the int C in Cut_TreeColors and make C a global int that way the int C in Cut_TreeDown would have a color to find.
    Thanks for that little explaination.

    [OFFTOPIC] Why aren't you a member yet? [/OFFTOPIC]
    Last edited by Coh3n; 07-07-2009 at 12:17 PM.

  8. #8
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    O_o. Show me what you have.

  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    O_o. Show me what you have.
    I just replaced my function with yours. The Runtime error was on this line:

    SCAR Code:
    FindColorsTolerance(TPA, TreeColor[c], TP.x - 20, TP.y - 20, TP.x + 20, TP.y + 20, Cut_ColorTolerance);

    EDIT: Oh because you don't use c. You use Result.

  10. #10
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It's also because it returns the color not the index number.

    SCAR Code:
    FindColorsTolerance(TPA, Cut_TreeColor, TP.x - 20, TP.y - 20, TP.x + 20, TP.y + 20, Cut_ColorTolerance);

  11. #11
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    It's also because it returns the color not the index number.
    Yeah I got it working, thanks a lot!

    <3

  12. #12
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you're welcome. If you need any more help feel free to add my MSN (kylewollaston@hotmail.com).

  13. #13
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    you're welcome. If you need any more help feel free to add my MSN (kylewollaston@hotmail.com).
    Done.

  14. #14
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    [OFFTOPIC] Why aren't you a member yet? [/OFFTOPIC]
    An application takes 2 weeks till its over and I get to be a member. 1 more day btw Then Ill be a SRL Member

  15. #15
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by TRiLeZ View Post
    An application takes 2 weeks till its over and I get to be a member. 1 more day btw Then Ill be a SRL Member
    Well congrats in advance.

  16. #16
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Man you are pretty much like me Always a little not noticeable problem Well i hope that your script is going to be great

    ~Home

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
  •