Results 1 to 6 of 6

Thread: First script - auto basketer

  1. #1
    Join Date
    May 2012
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default First script - auto basketer

    Hi this is my first try at scripting, I have followed the guide on the help and tutorials section thanks to Mayor.
    I have been making a bit of profit from buying fruit and then putting them in baskets, the profit vary's depending on what the GE prices are like. If you see your code in here im sorry but its probably stolen from a script you wrote :P.

    To set this is up you need to use preset 2, in this preset you want 4 baskets in the first 4 slots followed by fruit for the rest of the slots. The basket should be assigned to quick-slot 1 on the quick-slot bar.

    THE ONLY BANK SUPPORTED AT THE MOMENT IS DRAYNOR

    I am just looking for feedback and criticism on my code before I start on my other goal of making a master farmer pickpocketer followed by a dragon slayer script (not sure which dragon yet).

    I am by no means competent at scripting and I hardly understand it, but over time I may get better.

    This is from using apples
    ================================================== ======
    Cadets auto basketeer
    Time Run: 20 Minutes and 54 Seconds
    Baskets Filled: 724
    Loads Done: 181
    Profit Made: 289600
    Per Hour: 830883
    ================================================== ======

    Simba Code:
    program Basketeer;

    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}

    var
      LoadsDone, Slot, x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;

    ///*//////////////////////Start of player set up\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*\\\
    Const
      QuickKey   = 1;                   //The slot in which the basket is asigned to
      ProfitPB   = 400;                 //The amount of profit per basket filled, depends on fruit
      bankPin    = '';                  //Your bank pin
      BankLoc    = BANK_NPC_DRAYNOR;    //Change depending on the bank you are using

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := '';  //Enter user name here
        password := '';  //Enter password here
        isActive := true;
        isMember := true;
      end;
      currentPlayer := 0;
    end;
    ///*//////////////////////End of player set up\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*\\\

    Procedure FindNormalRandoms;
    Begin
      exitTreasure();
      claimTicket();
    End;

    procedure progressReport();
    var
      basketFilled, profit, profitPerHour: integer;
    begin
      basketFilled := LoadsDone * 4;
      profit := (basketFilled * ProfitPB);
      profitPerHour := round((profit * 60) / (getTimeRunning() / 60000));

      writeLn('========================================================');
      writeLn('Cadets auto basketeer');
      writeLn('Time Run: ' + timeRunning);
      writeLn('Baskets Filled: ' + intToStr(basketFilled));
      writeLn('Loads Done: ' + intToStr(loadsDone));
      writeLn('Profit Made: ' + intToStr(profit));
      writeLn('Per Hour: ' + intToStr(profitPerHour));
      writeLn('========================================================');
    end;

    procedure openBank();
    begin
      bankScreen.open(BankLoc);
      if (pinscreen.isOpen()) then
      writeln('Pinscreen is open!');

      if (pinScreen.enter(bankPin)) then
       writeln('Entered our bank pin!');

      if not bankScreen.isOpen then
        wait(650);

        begin
          if bankScreen.isOpen then
            exit;
          findColorsSpiralTolerance(x, y, TPA, 5385548, mainScreen.getBounds(), 16, colorSetting(2, 0.59, 0.72));

          if (Length(TPA) < 1) then
            exit;

          ATPA := TPA.toATPA(30, 30);
          ATPA.sortFromMidPoint(mainscreen.playerPoint);
          smartImage.debugATPA(ATPA);
          for i := 0 to high(ATPA) do
          begin
            mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
            if isMouseOverText(['anker'], 500) then
            begin
              fastClick(MOUSE_LEFT);
                break;
            end;
          end;
        end;
    end;

    procedure withdrawPreset();
    begin
      if (bankScreen.isOpen()) then
        begin
          bankScreen.clickButton(BANK_BUTTON_PRESET_2);
        end;
         inc(LoadsDone);
    end;
    procedure fillBasket();
    var
      timesTried:integer;
      T: TTimeMarker;
    begin
      FindNormalRandoms;
      If Not IsLoggedIn Then
        Exit;

      If TabBackpack.IsEmpty then
        Exit;

      T.Start;
      Repeat
        SendKeys(ToStr(QuickKey), 60 + Random(60), 60 + Random(60));
        Wait(GaussRangeInt(50,100));

        If Not IsLoggedIn Then
          Exit;

        If T.GetTime>15000 Then
          Exit;
      Until (T.GetTime>1450);
    End;


    {Main Loop}
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      repeat
      if not isLoggedIn() then
      begin
        players[currentPlayer].login();
        exitSquealOfFortune();
        Minimap.ClickCompass;
        MainScreen.SetAngle(MS_ANGLE_HIGH);
      end;

      openBank();
      Wait(RandomRange(500,1500));
      withdrawPreset();
      Wait(RandomRange(100,500));
      fillBasket();
      Wait(RandomRange(1700,2200));
      progressReport();
      until (false);
    end.

  2. #2
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Nice first script, but I saw this.

    Simba Code:
    if bankScreen.isOpen then
        bankTimer.start();
        exit

    Shouldn't that be

    Simba Code:
    if bankScreen.isOpen then
    begin
      bankTimer.start();
      exit;
    end;

    Since currently it will exit 100% of the time.

  3. #3
    Join Date
    May 2012
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    Nice first script, but I saw this.

    Simba Code:
    if bankScreen.isOpen then
        bankTimer.start();
        exit

    Shouldn't that be

    Simba Code:
    if bankScreen.isOpen then
    begin
      bankTimer.start();
      exit;
    end;

    Since currently it will exit 100% of the time.
    Balls, thanks didn't notice that.

  4. #4
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Nice first script It would be a good idea to put the bank and pin as constants so the user doesn't have so scroll half way down to input the info. A few little things:

    You should probably start using exitTreasure and claimTicket as the other ones were for SOF and will eventually be removed from SRL6.
    Simba Code:
    procedure findNormalRandoms();
    begin
      exitTreasure();
      claimTicket();
    end;

    Don't need a begin and end here, since there is just 1 statement after the then (or were you meant to put the inc inside the begin..end?).
    Simba Code:
    procedure withdrawPreset();
    begin
      if (bankScreen.isOpen()) then
        begin
          bankScreen.clickButton(BANK_BUTTON_PRESET_2);
        end;
         inc(LoadsDone);
    end;

    E: What's your bankTimer for

  5. #5
    Join Date
    May 2012
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Nice first script It would be a good idea to put the bank and pin as constants so the user doesn't have so scroll half way down to input the info. A few little things:

    You should probably start using exitTreasure and claimTicket as the other ones were for SOF and will eventually be removed from SRL6.
    Simba Code:
    procedure findNormalRandoms();
    begin
      exitTreasure();
      claimTicket();
    end;

    Don't need a begin and end here, since there is just 1 statement after the then (or were you meant to put the inc inside the begin..end?).
    Simba Code:
    procedure withdrawPreset();
    begin
      if (bankScreen.isOpen()) then
        begin
          bankScreen.clickButton(BANK_BUTTON_PRESET_2);
        end;
         inc(LoadsDone);
    end;

    E: What's your bankTimer for
    Thanks for the reply Mayor, um the timer was something I started but forgot about and haven't yet remembered what I was going to do with it :P.

    I will put in the bank pin as a constant as well as the profit per basket. Maybe even the bank you are using. I will put up an updated version soon.

    I might even experiment with player forms just so I have an idea of how to use it in my next script.

  6. #6
    Join Date
    May 2012
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Updated the script a bit according to the feedback of the Mayor and Olly, anything else that could be handled better or improved upon is much appreciated.

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
  •