Results 1 to 17 of 17

Thread: My Woodcutting Script

  1. #1
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default My Woodcutting Script

    Hey guys, some of you may know me from the IRC chat.

    Anyway, I'm making this thread cause I'm having trouble adding support for other trees in my script. I have an idea, though.

    Here's the script.

    Code:
    program Woodcutter;
    {$i srl/srl/misc/Smart.scar}
    {.include SRL/SRL.scar}
    {.include SRL/SRL/Skill/WoodCutting.scar}
    
    var x, y: integer;
    Loads: Integer;
    ChopTime: Integer;
    TreesChopped: Integer;
    Dropper: Integer;
    
    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name := ''; //RS Username
      Players[0].Pass := ''; //RS Password
      Players[0].Nick := ''; //4 letters of Username
      Players[0].Active := True;
      Players[0].Integers[0] := 30; //Number of loads you want to do
    end;
    
    //*************************************************\\
    ///////////////DON'T TOUCH BELOW HERE!\\\\\\\\\\\\\\\\
    //***************************************************\\
    
    procedure AntiRandoms;
    begin
      if not LoggedIn then Exit;
      FindNormalRandoms; // find random events
    end;
    
    procedure AntiBan;
    begin
      case random(100) of //do a random number so it won't always perform the antiban
        0: RandomRClick;
        1: BoredHuman;
        2: HoverSkill('Woodcutting', False);
      end;
    end;
    
    Procedure CutWood;
    begin
      if not LoggedIn then
      Exit;
      MakeCompass('N');
      repeat
         if FindObjCustom(x, y, ['ree'], [3164510, 3690597, 4020077], 25) then
          begin
          Mouse(x,y,0,0,false);
             Wait(40 + (random(20)));
             ChooseOption('hop');
          end;
      until(InvFull)
    end;
    
    Procedure Report;
    Begin
        cleardebug;
    
        Writeln(' Lets Cut Wood ')
        Writeln(' Worked For ' + TimeRunning);
        Writeln(' Chopped ' + IntToStr(TreesChopped));
        Writeln(' Dropped(by loads) ' + IntToStr(Dropper));
        Writeln(' By Gooner ');
    End;
    
    
    
    //////Thanks to DeSnob for this function\\\\\\
    
    Function IsChopping: Boolean;
    begin
      if (PixelShift(PointToBox(Point(MSCX-10, MSCY-10), Point(MSCX+10, MSCY+10)), +
          RandomRange(100, 200)) > 100) then
            MarkTime(ChopTime);
      Result := (TimeFromMark(ChopTime) < RandomRange(750, 1500));
    end;
    
    begin
      if not (LoggedIn) then
      Exit;
      ActivateClient;
      SetUpSRL;
      DeclarePlayers;
      Report;
      LoginPlayer;
      LevelUp;
    
      while(Loads <= (Players[CurrentPlayer].Integers[0]))do
      begin
        repeat
          CutWood;
          while (IsChopping) do
            Wait(500 + Random(100));
    
        until InvFull;
        DropAllExcept([1]);
        Inc(Loads);
      end;
    end.
    Now, that works nicely. All I want to do is add support for Oaks, Willows and Yews. I sort of have an idea on how to do this, but I'm not exactly sure. My guess would be to make a separate procedure for each tree type, then call some if - then statements, but I don't really know. Any help on adding these would be greatly appreciated.

    Also, Coh3n, if you happen to see this, I read the tutorial you showed me and followed it correctly, but it just wouldn't compile, no matter what I did.

    Also, feel free to post errors/suggestions.

    Thanks!
    Last edited by Gooneroo; 12-10-2011 at 09:08 AM.

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    This part right here is where you're searching for your tree colors:
    Simba Code:
    if FindObjCustom(x, y, ['ree'], [3164510, 3690597, 4020077], 25) then
    For something extremely simple you could do something like this:
    Simba Code:
    Const
      TreeType := 'normal';

    Procedure CutWood;
    var
      TreeColors: TIntegerArray;
    begin
      if not LoggedIn then
      Exit;
      MakeCompass('N');
      case LowerCase(TreeType) of
        'normal': TreeColors := [3164510, 3690597, 4020077];
        'oak': TreeColors := [];
        'willow': TreeColors := [];
        'yew': TreeColors := [];
      end;

      repeat
         if FindObjCustom(x, y, ['ree'], TreeColors, 25) then
          begin
          Mouse(x,y,0,0,false);
             Wait(40 + (random(20)));
             ChooseOption('hop');
          end;
      until(InvFull)
    end;

    Then where you see the 'oak' (ect) you can add your tree colors there.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Looks good, thanks. Wouldn't then the ['ree'] part need to be changed each time, as the UpText changes? Or does that not matter?

    Also, where the constant is, that's where the User chooses the tree they want to use, correct?

    Thanks again

    EDIT: Also, do I edit my current CutWood, or make a completely new one?

    Tried doing it so I edit my current CutWood. When I do -

    Simba Code:
    Const
      TreeType := 'normal';

    Doesn't compile.

    Simba Code:
    Const
      TreeType = 'normal';

    That does.
    Last edited by Gooneroo; 12-10-2011 at 10:05 AM.

  4. #4
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Yes, that is where the user of your script would input what tree they would like to be cut down.
    The "['ree']" part is perfectly fine. It does not need to be changed.
    Don't change the function in question completely, simply use Flight's suggestion. It's good for what you are attempting to do.

  5. #5
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    How is the ['ree'] part fine - isn't it UpText? When I tried to use it, it would right click on the oak, even though it would find it. It then found a normal tree, and clicked on that.

    Also, do you know how to fix - Error: Exception: Access violation at line 86?

    Line 86 is: result:= SmartGetColor(x, y);

    Thanks for your help, appreciate it very much. It's my first script.

  6. #6
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah, you are right. I'm sorry, I wasn't in the right mind set when I answered that concern. You should, if you can, change the uptext to match accordingly to the tree that you are attempting to cut. You can use capital letters such as "Oak" or "Tree".

    I am unsure of what that error is. You could try posting in the help section though if you want. Or wait until someone replies to the question here.

  7. #7
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks RISK. No need to apologise, I'm just happy I figured out something on my own!

    Is it possible to make it so the uptext automatically changes to 'ak', 'illow' etc, so I don't have to ask the player to go down to line x and change it themselves? Hope you understand what I'm trying to say.

  8. #8
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Try this:
    Simba Code:
    procedure Example;
    var
      treeCol : TIntegerArray; // Array for the tree's colors
      treeTex : string; // String for the tree's uptext
    begin
      case Lowercase(TreeType) of
        'normal' :
          begin
            treeCol := [00000, 11111, 22222];
            treeTex := 'Tree';
          end;
      end;

      if FindObjCustom(X, Y, [treeTex], treeCol, 15) then
      begin
      end;
    end;

  9. #9
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Where would I apply that? Is it separate to my CutWood Procedure?

  10. #10
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You would put it in to your wood cutting procedure.

  11. #11
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Simba Code:
    procedure CutWood;
    var
      treeCol : TIntegerArray; // Array for the tree's colors
      treeTex : string; // String for the tree's uptext
    begin
      case Lowercase(TreeType) of
        'normal' :
          begin
            treeCol := [3164510, 3690597, 4020077];
            treeTex := 'Tree';
          end;
      end;

      if FindObjCustom(X, Y, [treeTex], treeCol, 15) then
          begin
          Mouse(x,y,0,0,false);
             Wait(40 + (random(20)));
             ChooseOption('hop');
          end;
      until(InvFull)
    end;

    Where have I gone wrong? I get an error - [Error] (67:3): Identifier expected at line 66
    Compiling failed.

    Line 66 is until(InvFull).

  12. #12
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You need a matching 'repeat' for that 'until' and you also need a begin end nest for the FindObj.

  13. #13
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Fixed! Thanks Now I need to run it, but I can't in SMART cause of that Line 86 error, and every time I try to run it in a browser it takes control of my computer. :/

    Instead of testing it, I'm going to ask this. Here's what I have: http://paste.villavu.com/show/JkTPfNu1W2czzwbRt42Y/

    What needs to be done to finalise that?

    Thanks again
    Last edited by Gooneroo; 12-10-2011 at 10:54 AM.

  14. #14
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Try completely updating your stuff. I don't get that error.

    Do you want to add my MSN for more direct help? riskeditall@live.com

  15. #15
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Will do man. Just need to install MSN, as I'm on a Virtual Machine and I haven't installed it.

  16. #16
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Gooneroo View Post
    Tried doing it so I edit my current CutWood. When I do -

    Simba Code:
    Const
      TreeType := 'normal';

    Doesn't compile.

    Simba Code:
    Const
      TreeType = 'normal';

    That does.
    Yeah you'll have to forgive me, I just threw that together without compiling or anything. Anything defined as a constant only need a "=", static variables would be ":=" which is what I used on accident. You did good by catching my mistake, nice job Gooneroo.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  17. #17
    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Cool Flight, 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
  •