Page 2 of 2 FirstFirst 12
Results 26 to 44 of 44

Thread: [SRL]How To Write Your First Script: Collecting and Banking Cabbages!

  1. #26
    Join Date
    Jun 2018
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thanks for this guide, its appreciated !

    Do you have any plans of making more guides ?

  2. #27
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

    Default

    Quote Originally Posted by Define Define View Post
    Thanks for this guide, its appreciated !

    Do you have any plans of making more guides ?
    I definitely can if you are interested. I am planning on doing one that builds off of this one and is a bit more complex.

  3. #28
    Join Date
    Jun 2018
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by StickToTheScript View Post
    I definitely can if you are interested. I am planning on doing one that builds off of this one and is a bit more complex.
    Yea I am most certainly interested

    This guide really helped me so far. Looking forward to your next guide.

  4. #29
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by StickToTheScript View Post
    I definitely can if you are interested. I am planning on doing one that builds off of this one and is a bit more complex.
    Our resident SRL Tutorial Writer has been doing lots of good work lately, the forums are the perfect place for documentation and your posts are invaluable. Thanks!
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  5. #30
    Join Date
    Jun 2007
    Posts
    310
    Mentioned
    0 Post(s)
    Quoted
    84 Post(s)

    Default

    Thank you very much for this. Have linked it to a mate as well... this is how we get more people writing scripts

  6. #31
    Join Date
    Nov 2007
    Posts
    187
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Would be awesome if you made another guide, on different parts of Srl.

  7. #32
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

    Default

    Quote Originally Posted by hellian46 View Post
    Would be awesome if you made another guide, on different parts of Srl.
    I plan to make another in about a month or so. Gotta free up some time first.

  8. #33
    Join Date
    Feb 2015
    Posts
    48
    Mentioned
    0 Post(s)
    Quoted
    12 Post(s)

    Default

    This is a great tutorial! Thanks for sharing

    For those how have troubles with the ACA v3 Extension, I made a quick guide on how to "install" it: https://villavu.com/forum/showthread.php?t=118410

  9. #34
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    I have referenced this tutorial countless times while learning SRL, thank you very much for this valuable resource.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  10. #35
    Join Date
    Nov 2018
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Hey man great guide! Really helped me a lot! I'm using this tutorial to make a fishing script, but i'm trouble with finding the fishing spots. Any Suggestions?

  11. #36
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

    Default

    Quote Originally Posted by Hellserver View Post
    Hey man great guide! Really helped me a lot! I'm using this tutorial to make a fishing script, but i'm trouble with finding the fishing spots. Any Suggestions?
    @slacky Created a pretty accurate method which did this. You can take a look at what he did below and attempt to replicate it yourself by figuring out what is going on and seeing if you can put your own spin on it. Otherwise, if you plan on using it, please do not forget to give him credit.

    Simba Code:
    // Find fishingspots by finding the edges of the water, over and over again
    // Then do some fancy stuff to remove land->water borders.
    // what's left is an accurate TPA of the fishingspot
    function TFisher.FindFishingSpot(scanTime: Int32=450): T2DPointArray;
    var
      i: Int32;
      SUM,TPA: TPointArray;
      R: TRectangle;
      t: TCountDown;
    begin
      t.Init(scanTime);
      while not t.IsFinished do
      begin
        srl.FindColors(TPA, CTS2(8875103,16,0.2,0.7), Mainscreen.GetBounds);
        SUM += TPA.Edges();
      end;

      SUM.ClearDuplicates();
      SUM := ClearTPAFromTPA(Sum, Sum.Edges());
      Result := SUM.Cluster(5);
      Result.FilterSize(12, __GT__);

      {$ifdecl TWindowOverlay}
      Debug.Clear();
      for i:=0 to High(Result) do
        Debug.DrawTPA(Result[i], Random($FFFFFF));
      {$endif}
    end;
    Last edited by StickToTheScript; 11-09-2018 at 03:37 PM.

  12. #37
    Join Date
    Nov 2016
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    For search reference, you probably got this error or something close to it.
    Simba Code:
    xcorr   := WorldSample.MatchTemplate(mmsample, Self.TMFormula);

    Runtime error: "Access violation" at line 209, column 41 in file "C:\Simba 1.3\Includes\RSWalker\Walker.simba"
    Succesfully executed in 28297 ms.
    The following bitmaps were not freed: [0, Minimap mask, Smart[13256] Image, 3, 4]

    Something that took me a while to figure out, but ended up finding it in the discord (Thanks Olly)
    Is that the init method changed, from now on just call Walker.Init('mapname') and no more parameters.

    In the tutorial there is still a -1 parameter written.
    Simba Code:
    Walk.Init('world.png', -1);    //Setup RSWalker by initializing the map we want to use

    So if you just remove the -1 it works as it is expected from the tutorial.

    Simba Code:
    Walk.Init('world.png');    //Setup RSWalker by initializing the map we want to use

  13. #38
    Join Date
    Jun 2019
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    is there any way to use this on a osrs sourced private server

  14. #39
    Join Date
    Jul 2018
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by bobbersssss View Post
    is there any way to use this on a osrs sourced private server
    If the client and the version is the same as OSRS it should work

  15. #40
    Join Date
    Jun 2019
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by felparers View Post
    If the client and the version is the same as OSRS it should work
    is there a way to define my rsps client instead of the osrs client?

  16. #41
    Join Date
    Jul 2018
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Drag the target( green + on toolbar) on the client you want to use.

  17. #42
    Join Date
    Oct 2010
    Location
    Brasil PR Ponta Grossa
    Posts
    96
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    I've Put You script to kill Flesh crawlers lol, but the mouse is moving to fast, any Ideas to made the mouse move more naturaly, and how to put some antiban?
    program new;
    {$define SMART}
    {$I SRL/OSR.simba}
    {$I RSWalker/Walker.simba}

    const //This is where we declare our constants
    LOGIN_NAME = ''; //Username/Email
    LOGIN_PASS = ''; //Password
    RS_WORLD = -1; //Desired World (-1 = Random)
    IS_MEMBER = false; //True if your player is a Member

    var //This is where we declare our variables
    Walk: TRSWalker; //Used for RSWalker (to walk paths)

    {************************************************* ******************************
    Name: declarePlayers();
    Function: Sets the proper variables using the constants above to allow
    a successful login.
    ************************************************** *****************************}
    procedure declarePlayers();
    begin
    with Players.New()^ do
    begin
    LoginName := LOGIN_NAME;
    Password := LOGIN_PASS;
    IsActive := True;
    IsMember := IS_MEMBER;
    World := RS_WORLD;
    end;
    Players.SetCurrent(0);
    end;

    {************************************************* ******************************
    Name: waitLoop();
    Function: Waits until we have collected our cabbage
    ************************************************** *****************************}
    procedure waitLoop();
    var
    InvCount: Integer;
    T: TTimeMarker;
    begin
    if not SRL.isLoggedIn() then
    Exit;

    InvCount := Inventory.Count(); //Gets the count in our inventory
    T.Start; //Start our timer
    repeat
    wait(randomRange(75, 250)); //Wait a random amount of time
    until((Inventory.Count() > InvCount) or (T.GetTime > 7000)); //Stop repeating once inv count changes or we time out
    end;

    {************************************************* ******************************
    Name: findCabbages();
    Function: Locates cabbage in the field. Will print on screen if using SMART.
    ************************************************** *****************************}
    procedure findCabbages;
    var
    TPA, Cabbage: TPointArray;
    ATPA: T2DPointArray;
    begin
    if not SRL.isLoggedIn() then //If not logged in, then terminate script
    TerminateScript;

    if (SRL.FindColors(TPA, CTS2(6688, 2, 0.29, 0.00), MainScreen.GetBounds) > 0) then //If we find colours at all then...
    begin
    ATPA := TPA.Cluster(2); //Group them within a max pixel distance of 2
    ATPA.FilterSize(100, 500); //Remove and ATPA of size < 100, or > 500.
    ATPA.SortByIndex(MainScreen.GetMiddle); //Sort by closest to Middle of the screen

    {$IFDEF SMART} //If we are using SMART, then...
    Smart.Image.DebugATPA(ATPA);
    {$ENDIF} //End SMART IF

    for Cabbage in ATPA do //For every possible cabbage in our ATPA
    begin
    Mouse.Move(Cabbage[Random(Length(Cabbage))]); //Move the mouse to the cabbage

    if MainScreen.IsUpText('Attack') then //If the uptext is 'Cabbage', try to click it
    begin
    if Mouse.Click(ctRed) then //Clicks the mouse and looks to see if red 'x' appeard when cicked
    begin
    waitLoop(); //Call to our waitLoop because we want to wait while picking.
    Break; //If found red 'x', then break because we clicked it
    end;
    end;
    end;
    end;

    {$IFDEF SMART}
    Smart.Image.Clear; //Clears the ATPA's from screen
    {$ENDIF}
    end;

    {************************************************* ******************************
    Name: setUp();
    Function: Sets up the script by initializing everything and logging player in.
    ************************************************** *****************************}
    function setUp(): boolean;
    begin
    {$IFDEF SMART} //If we are using SMART, then...
    Smart.EnableDrawing := True; //let us draw on SMART
    {$ENDIF} //end SMART IF

    SRL.Setup([]); //Setup SRL to allow us to access it's functions.

    Walk.Init('world.png', -1); //Setup RSWalker by initializing the map we want to use

    declarePlayers(); //Declare the player we are using

    if (not SRL.isLoggedIn) then //If not logged in then..
    begin
    Players.LoginCurrent(); //Log player in
    MainScreen.setAngle(True); //Sets the camera angle to the highest point
    end;
    end;

    begin //Main
    if setUp then //Calls the setup of the script
    writeln('We are set up and ready to go!');
    repeat
    findCabbages(); //Collect Cabbages until inv is full
    until(false); //Repeats forever
    end.
    begin
    FindNormalRandoms;
    case Random(90) of
    0: RandomRClick;
    2: PickUpMouse;
    3: RandomMovement;
    4: BoredHuman;
    5: ExamineInv;
    6: MakeCompass('N');
    7: SetAngle(SRL_ANGLE_HIGH);
    8: Wait(5000+random(2000));
    9: HoverSkill(skill_attack,false);
    end;

  18. #43
    Join Date
    Feb 2013
    Location
    United States
    Posts
    53
    Mentioned
    2 Post(s)
    Quoted
    12 Post(s)

    Default

    This was a valuable learning exercise for me, to try and rework this script to work with latest SRL-Dev and simba from olly's github.

    I've noticed a ton of things don't quite work for me:
    1) Smart doesn't work at all
    2) Include log in function doesn't hit the "Login" button after typing in information
    3) Include doesn't change camera angle
    4) RSWalker is included in SRL-Dev so no need for separate dependency
    5) Open bank at tile wasn't working for me, maybe I was using tile coords instead of screen coords, but don't know how to tranlate that without reflection method
    6) Lots of little syntax changes between the old and new include, most of the antiban section for example.
    7) The ACA bit of the tutorial with the color picker tool still works perfectly well

    I was able to piece together the components and this is what I came up with -- it may be sloppy but at least I got it to run again as it was intended. Sharing it here for anyone who may follow the main link path for getting introduced to this community:

    Simba Code:
    program cabbage;
    {$define SMART}
    {$I SRL/OSR.simba}

    //Declare our Constants
    const
      LOGIN_NAME = '';    //Username/Email
      LOGIN_PASS = '';    //Password

    //Declare our variables
    var
      Walk: TRSWalker;            //Used for RSWalker (to walk paths)
      pathToPatch: TPointArray;


    {*******************************************************************************
      Name: declarePlayers();
      Function: Sets the proper variables using the constants above to allow
        a successful login.
    *******************************************************************************}

    procedure declarePlayers();
    begin
      Login.AddPlayer(LOGIN_NAME, LOGIN_PASS);
    end;

    {*******************************************************************************
      Name: setupAntiban();
      Function: Sets up the built-in antiban included with the SRL include.
      NOTE: Please feel free to customize this and make it unique to you.
    *******************************************************************************}

    procedure setupAntiban();
    begin

      Antiban.AddTask(ONE_MINUTE*5, @Antiban.LoseFocus);
      Antiban.AddTask(ONE_MINUTE*10, @Antiban.HoverSkills);
      Antiban.AddTask(ONE_MINUTE*10, @Antiban.RandomTab);
      //Antiban.AddTask(ONE_MINUTE*25, @Antiban.VeryShortBreak);
      //Antiban.AddTask(ONE_MINUTE*25, @Antiban.DoMiscStuff);
      //Antiban.AddTask(ONE_MINUTE*45, @Antiban.RandomCompass);

      Antiban.AddBreak(35*ONE_MINUTE,05*ONE_MINUTE,0.05, 0.03);
      Antiban.AddBreak(02*ONE_HOUR,05*ONE_MINUTE,0.20, 0.85);
      Antiban.AddBreak(05*ONE_HOUR,05*ONE_MINUTE,0.85, 0.85);
      Antiban.AddBreak(16*ONE_HOUR,05*ONE_MINUTE,0.99, 0.99);
    end;

    {*******************************************************************************
      Name: setUp();
      Function: Sets up the script by initializing everything and logging player in.
    *******************************************************************************}

    function setUp(): boolean;
    begin
      SRL.Setup();                 //Setup SRL to allow us to access it's functions.
      Walk.Setup('world');     //Setup RSWalker by initializing the map we want to use
      declarePlayers();              //Declare the player we are using
      pathToPatch := [[4177, 3463], [4159,3449], [4135, 3436], [4128, 3402], [4121, 3364], [4089, 3335], [4049, 3335], [4024, 3310], [4025, 3288], [4025, 3288]];
      setupAntiban();                //Setup our antiban

      if not Login.LoginPlayer() then
        TerminateScript('Failed to login!');
      MainScreen.SetHighestPitch();  //this doesn't actually do anything atm

      Result := True;
    end;

    {*******************************************************************************
      Name: myAntiban();
      Function: Executes the antiban and checks for random events.
    *******************************************************************************}

    Procedure myAntiban;
    begin
      if (not RSClient.IsLoggedIn) then
        Exit;

      Antiban.DismissRandom();  //Dismiss random events if any are found
      Antiban.DoAntiban();  //Do the antiban
    end;

    {*******************************************************************************
      Name: waitLoop();
      Function: Waits until we have collected our cabbage
    *******************************************************************************}

    procedure waitLoop();
    var
      InvCount: Integer;
      T: TStopwatch;
    begin
      if (not RSClient.IsLoggedIn) then
        Exit;

      InvCount := Inventory.Count(); //Gets the count in our inventory
      T.Start;                       //Start our timer
      repeat
        myAntiban();
        wait(randomRange(75, 250));  //Wait a random amount of time
      until((Inventory.Count() > InvCount) or (T.ElapsedTime > 7000)); //Stop repeating once inv count changes or we time out
    end;

    {*******************************************************************************
      Name: findCabbages();
      Function: Locates cabbage in the field. Will print on screen if using SMART.
    *******************************************************************************}

    procedure findCabbages();
    var
      TPA, Cabbage: TPointArray;
      ATPA: T2DPointArray;
      CabbageColor: TCTS2Color;
    begin
      if (not RSClient.IsLoggedIn) then    //If not logged in, then terminate script
        TerminateScript;

      CabbageColor := CTS2(2727797, 20, 0.05, 1.15);
      if (SRL.FindColors(TPA, CabbageColor, MainScreen.Bounds) > 0) then //If we find colours at all then...
      begin
        ATPA := TPA.Cluster(2);                 //Group them within a max pixel distance of 2
        ATPA.FilterSize(100, 500);              //Remove and ATPA of size < 100, or > 500.
        ATPA.SortByIndex(MainScreen.Center); //Sort by closest to Middle of the screen

        for Cabbage in ATPA do                  //For every possible cabbage in our ATPA
        begin
          Mouse.Move(Cabbage[Random(Length(Cabbage))]); //Move the mouse to the cabbage

          if MainScreen.IsUpText('Cabbage') then        //If the uptext is 'Cabbage', try to click it
          begin
            Mouse.Click(MOUSE_LEFT);
            if (not MainScreen.DidRedClick) then Exit;
            waitLoop();                       //Call to our waitLoop because we want to wait while picking.
            Break;
          end;
        end;
      end;
    end;

    function manualBank(): boolean;
    var
      TPA, BankBooth: TPointArray;
      ATPA: T2DPointArray;
      BankColor: TCTS2Color;
    begin
      if (not RSClient.IsLoggedIn) then    //If not logged in, then terminate script
        TerminateScript;

      BankColor := CTS2(5527903, 5, 0.71, 0.53);
      writeln("Looking for bank via ATPA");
      if (SRL.FindColors(TPA, BankColor, MainScreen.Bounds) > 0) then //If we find colours at all then...
      begin
        writeln("found some potential banks");
        ATPA := TPA.Cluster(2);                 //Group them within a max pixel distance of 2
        ATPA.SortByIndex(MainScreen.Center); //Sort by closest to Middle of the screen

        for BankBooth in ATPA do                  //For every possible BankBooth in our ATPA
        begin
          writeln(BankBooth);
          Mouse.Move(BankBooth[Random(Length(BankBooth))]); //Move the mouse to the BankBooth

          if MainScreen.IsUpText('Bank booth') then        //If the uptext is 'BankBooth', try to click it
          begin
            Mouse.Click(MOUSE_LEFT);
            Result:= True;
            Exit;
          end;
        end;
      end;
    end;

    begin //Main
      if setUp then
        writeln('We are set up and ready to go!');

      repeat
        if not Inventory.IsFull then
        begin
          Writeln("Walking to cabbage patch!");
          Walk.WalkPath(pathToPatch);
        end

        while (not Inventory.IsFull) do
        begin
          findCabbages();   //Collect Cabbages until inv is full
        end

        Writeln("Walking to bank!");
        Walk.WebWalk(WorldWeb.LOCATION_DRYNOR_BANK);    //Walk to Bank

        while (not manualBank) do  //open bank
        begin
          Writeln("Trying to open bank");
          wait(randomRange(75, 250));
        end;

        while Bank.IsOpen(5000) do
        begin
          writeln("trying to deposit");
          wait(randomRange(75, 250));
          Bank.DepositAll();
          wait(randomRange(75, 250));
          Bank.Close();
        end
      until(false);
    end.

  19. #44
    Join Date
    Jan 2012
    Posts
    64
    Mentioned
    0 Post(s)
    Quoted
    21 Post(s)

    Default

    Big thanks for this tutorial! And also thanks to Vizzyy for his post above

Page 2 of 2 FirstFirst 12

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
  •