Results 1 to 22 of 22

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

  1. #1
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,144
    Mentioned
    25 Post(s)
    Quoted
    430 Post(s)

    Post How To Write Your First Script: Collecting and Banking Cabbages!

    How To Write Your First Script: Collecting and Banking Cabbages!



    Introduction

    Hello everyone,

    This is a tutorial on how to create your very first script using Simba and SRL6. There are two very useful tutorials that teach you the basics and what is available to you. These two tutorials are written by @The Mayor, and can be found here:


    The Mayor wrote out a script for you that runs, teleports, banks, and mines for you, but in-case you wanted a bit more of an explanation, you can freely read this tutorial.




    What to expect in this tutorial

    If you are new to Simba and SRL, or just do not have a good comprehension of scripting in general, this should help you out quite a bit.

    We will be covering a lot of stuff, such as how to setup the script, create functions and procedures, how to use them properly, walking using SPS (More on this later), finding objects on the screen and clicking them, and even banking.

    I will be referring quite often to The Mayor's tutorials. Please make sure you have read those.

    We will be using tools such as ACA and SPS_Path_Generator, which will also be covered later.

    So, lets get started...





    Part 1: The Skeleton

    Whenever you start scripting, you will want to start with a skeleton. What is it?! Let me show you...

    Simba Code:
    program scriptTemplate;

    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := 'username';
        password := 'password';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;


    // main loop
    begin
      clearDebug();               // Clear the debug box
      smartEnableDrawing := true; // So we can draw on SMART
      setupSRL();                   // Load the SRL include files
      declarePlayers();             // Set up your username/pass

      if not isLoggedIn() then             // If player isn't logged in then
      begin
        players[currentPlayer].login();   // Log them in
        exitTreasure();            // Exit treasure hunter
        minimap.setAngle(MM_DIRECTION_NORTH);  // Make compass north and angle high
        mainScreen.setAngle(MS_ANGLE_HIGH);
      end;

    end.

    This skeleton is from The Mayor's tutorial, which is linked above. To save as a default skeleton (HIGHLY RECOMMENDED), Simply copy and paste into untitled tab, click 'File', and then click 'Save as Default'.


    This should be pretty self explanatory, but if not, the script simply logs the character in and adjusts the compass and angle.

    I should not have to tell you too much about this because you should have read The Mayor's tutorials already.




    Part 2: Before You Start To Actually Script...

    Before the actual scripting starts, its always good to create a basic layout of what you want the script to do. In this case, we are going to be writing a script that Starts at the Combat Academy Chest in Lumby, and we are going to have it walk to the cabbage patch, pick up a full inventory, walk back to the bank, open bank, deposit all object and close bank, and then repeat.

    To start off, we are going to create procedures and functions for each of those steps...

    So, with the knowledge you now have, you should have a script that looks reletively similar to this:

    Simba Code:
    program scriptTemplate;

    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := '';
        password := '';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;

    procedure walkToCabbies();
    begin

    end;

    procedure walkToBank();
    begin

    end;

    procedure clickCabbies();
    begin

     end;

    procedure bank();
    begin

    end;

    procedure depositLoot();
    begin

    end;

    procedure mainLoop();
    begin

    end;

    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);

    end.

    As you can see, we have a lot of procedures. You can freely make some of them functions to help you with fail-safes, but I just want to get to the point, so I'm leaving them all as procedures.

    So, that is our essential layout. You will notice that I have a Mainloop. You might be thinking "Why would he have a mainloop?", well let me explain.

    A mainloop is not essential, but it helps. It keeps things organized and allows things to look a bit more clean. It also helps you as a scripter to know where the 'control room' is. It is the place where all of our stuff happens, where things get told to run, and where things get repeated and checked, etc!

    Anyways, lets continue..




    Part 3: The Fun Scripting Part!

    Finally, we are where we need to be with the scripting part. How does it work? You should know the basics by now. If not, go read The Mayor's tutorials at the top of this tutorial.

    Where should we start with the scripting? Wherever you want! But for today, we will start with the banking procedure.





    3.1: Banking

    Some people have different ways of banking. Some people make their own forms of banking, while others use the built-in banking options that come with SRL6. Today, we will be using the built-in options.

    To do this, we will be banking at this chest:



    To use this chest, we have a wonderfully easy piece of code we can use.

    This would be:

    Simba Code:
    bankScreen.open(BANK_CHEST_LUMBRIDGE)

    This simply does all the work for you. So, what I have done is put it into the procedure 'bank'.

    Simba Code:
    procedure bank();
    begin
      if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
        wait(randomrange(1500,2500))
      else
      begin
        writeln('Did not open bank. We failed. Termination in progress.');
        Terminatescript;
      end;
    end;

    Now, as you can see, I put the open bank option in an If...Then... statement. Why? Because we are telling the script to run the open bank option, but in a slightly different way. The reason why I wrote it like this is because we can give it a wait. The reason I give it a wait is because I like to play it safe and give room for lag.

    You will notice that after the else statement, I have the writeln line, along with the terminate line. That is a fail-safe in the case that the script cannot find the bank. It will tell you that it couldnt find the bank, and then it will stop the script.

    You can freely write it in a different way, where it repeats until the bank is open, but that is up to you.



    3.2: Depositing The Cabbages

    Yep! We get to deposit.

    This part is really not hard because SRL6 also comes with some built-in options for this too!

    So, for the script, this is what I have written out:

    Simba Code:
    procedure depositLoot();
    begin
    if bankScreen.isOpen() then
      begin
        bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
        wait(randomRange(1000, 2000));
        bankScreen.close();
      end else
      begin
        writeLn('Couldn''t find the bank for some reason!');
        Terminatescript;
      end;
    end;

    Now, notice I have it check for the bank screen. The reason why is because the script would not be able to deposit anything if the bankscreen wasnt open. So, I have it check for it, and if it is, you see that it will deposit everything in the inventory, and then proceed to close the bank. I also have a wait between the deposit and the close options in the bank. This is just so that things don't happen too fast.

    Same as in the previous procedure for the bank, we have the writeln and terminate lines.


    Another possible way to deposit into the bank is by setting up a preset. You can setup a preset to be blank and when it clicks the preset button, it will deposit and close the bank. This shortens the amount of code needed, plus you do not need to add the bankScreen.close() line. You could write it as such:

    Simba Code:
    procedure depositLoot();
    begin
      if bankScreen.isOpen() then
      begin
        // Configure which preset to use in the setup
        bankScreen.clickButton(PRESET_BUTTON)
        // where PRESET_BUTTON is a user setup constant
      end else
      begin
        writeLn('Couldn''t find the bank for some reason!');
        Terminatescript;
      end;
    end;
    Thanks to @Incurable for the idea (post is below).







    3.3: Walk To Cabbages

    Alright. This is where we get the fun of using SPS!

    SPS is a great tool for trying to walk around Runescape. To read more about it, you can read here:

    SRL Positioning System (OFFICIAL THREAD)

    The Mayor also explains it wonderfully in his All-In-One RS3 Tutorial, which is at the top of this thread. I will show you how I made my map using the SPS Path Generator tool found here.

    So, I loaded my Lumby.png picture that I have saved in my C:\Simba\Includes\SPS\img\runescape_surface folder. You will want to save pictures for SPS there because you will use that location to call them in the script. We will get to that right now.


    So, before we do any walking or anything, we need to setup the script for SPS. To do this, we need to include it at the top of our script, which we did with the skeleton posted above, where you see SPS is included in the script.

    We also need to include a bit of extras in the setup part of the script.

    This is what you should add:

    Simba Code:
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      SPS.setup('Lumby', RUNESCAPE_SURFACE); //NOTICE THIS
      SPSanyangle := false;

        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);

    end.

    Here we set up SPS using the SPS.setup option written into the SPS include. This allows us to use SPS. Notice how we also loaded our picture 'Lumby' and stated that it is in the RUNESCAPE_SURFACE folder. If you have not downloaded the Lumby.png yet, it will be at the bottom of this tutorial.

    Note: If the picture is not in the RUNESCAPE_SURFACE folder, then the script will not load a SPS map, and therefore will not walk.




    Now, back to the walk to cabbages part...

    With the SPS tool that I linked above, we will create a path like this:



    This path is not the exact one written in the procedure below. But it is pretty close...

    Now, to copy a path that you made, click the 'Copy Path Array' button at the top of the client.

    Now, the basis of the procedure:

    Simba Code:
    procedure walkToCabbies();
    var
      pathToCabbies: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToCabbies := [Point(215, 172), Point(203, 172), Point(189, 167), Point(173, 165), Point(165, 159), Point(154, 150), Point(140, 139), Point(140, 124), Point(133, 120), Point(126, 114), Point(119, 109), Point(104, 107)];

      if SPS.walkPath(pathToCabbies) then
        minimap.waitPlayerMoving()
      else
        writeln('Failed Walk to Cabbies...');
    end;

    Alright. This procedure will walk you to where you need to go, which is the cabbage field in this case. Notice how we have our variables called. Dont forget to do this, or the script wont work.

    We also loaded the Path to Cabbages, and we told the script to walk using SPS.walkPath().

    Notice I also used the minimap.waitPlayerMoving() option. I used that to make sure that we were not moving so that our mouse doesn't go crazy when looking for colours. I consider it a fail-safe. You can also use it in other situations, which you will see later when we begin to pickup cabbages.





    3.4: Finding and Clicking on the Cabbies!

    There are many ways to find and pickup cabbages. In this case, what we are going to do is use my good friend mainscreen.findObject().

    Here is what our Cabbages look like:



    Here is our basic procedure for finding cabbages:

    Simba Code:
    procedure clickCabbies();
    var
      x, y: integer;
    begin
      if not isLoggedIn() then
        exit;

        mainscreen.findObject(x, y, 2602604, 19, colorSetting(2, 0.23, 0.88), mainscreen.playerPoint, 5, 5, 5, ['abbage'], MOUSE_LEFT);
        wait(randomrange(2000,3500));
        minimap.waitPlayerMoving();
    end;

    The colours have already been chosen using the ACA tool found here.

    When choosing colours, your goal is to pick as many possible unique colours that there are for the specific object. You also want to have the object as close to completely coloured red in the ACA tool like this:




    What we are doing here is finding our cabbage colours on the main RS screen and then waiting after we clicked. Notice I used the minimap.waitingPlayerMoving() again. This is because we don't want to be moving when the script begins to try to find more cabbage!

    Once again, I will state that if you do not understand what a lot of this stuff is, please read The Mayor's tutorials. It will go into greatly explained detail of how the mainscreen.findobject works and what each little setting stands for.





    3.5: Walk back to bank

    To walk back to the bank, you can simply copy the same procedure you used for walking to the cabbages, but you simply rename the path variable and reverse the path. Like this:

    Simba Code:
    procedure walkToBank();
    var
      pathToBank: TPointArray; //Variable changed to pathToBank
    begin
      if not isLoggedIn() then
        exit;

      pathToBank := [Point(104, 107), Point(119, 109), Point(126, 114), Point(133, 120), Point(140, 124), Point(140, 139), Point(154, 150), Point(165, 159), Point(173, 165), Point(189, 167), Point(203, 172), Point(215, 172)]; //Path Reversed

      if SPS.walkPath(pathToBank) then
        minimap.waitPlayerMoving()
      else
        writeln('Failed Walk to Bank...');
    end;

    This does the same thing as the SPS path that was done above.


    This now is all of the main procedures that we need. We will now move onto the MainLoop!





    3.6: Mainloop

    Now we have to get our script to work. To do so, we are going to make our MainLoop. Our MainLoop contains our procedures and functions in the order in which we want them to run. You need to know that you cannot have a working script without calling the procedures. I've seen it before where people write functions and procedures and they do not call them in their MainLoop or at the bottom of their script, yet they are expecting it to work. If you want more clarification on this part, you can contact me and I will explain further, but you should be able to understand that if you want a procedure or function to run in the script, you must call it at some point (either indirectly or directly in the mainloop).

    Our happy Mainloop will look like this:

    Simba Code:
    procedure mainLoop();
    begin

      walkToBank;
      bank;
      depositLoot;
      walkToCabbies;

      repeat
        clickCabbies;
      until tabBackPack.isFull();

    end;

    Our MainLoop is very basic as of this moment. It simply calls the other procedures above it.

    DO NOTE: A problem a lot of scripters have at the beginning is that they think that they can place procedures and functions wherever they want in the script. You CANNOT do that. This is because the script reads from the top down when compiling. If you were to try and put the mainloop under the delcarePlayers procedure, then the script would give you a compiling error.

    This mainloop will get the job done, but realize that there are no fail-safes in it at the moment. That is where you get to be creative and make ways to have the script recover if there is a problem that it encounters.

    In the Simba Code, you can see that the process is that the script will walk to the bank, open the bank, deposit the cabbages, close the bank, walk to the cabbages, pick up cabbages, and repeat.


    Now, you might be thinking, "How do I get the script to run the mainloop?!"

    Well, let me show you.

    Remember this:

    Simba Code:
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      SPS.setup('Lumby', RUNESCAPE_SURFACE);
      SPSanyangle := false;

        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);

    end.


    You are going to want to add a small bit of code to it.. Three lines to be exact...

    Simba Code:
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      SPS.setup('Lumby', RUNESCAPE_SURFACE);
      SPSanyangle := false;

        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);

      repeat
        mainLoop();
      until false;
    end.


    It simply repeats the mainloop forever!

    This will now call the mainloop into action, and go through the mainloop on a loop. Now, do note that you can run the script without a main loop, but it will look like this:

    Simba Code:
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      SPS.setup('Lumby', RUNESCAPE_SURFACE);
      SPSanyangle := false;

        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);

      repeat

        walkToBank;
        bank;
        depositLoot;
        walkToCabbies;

        repeat
          clickCabbies;
        until tabBackPack.isFull();

      until false;
    end.

    But I find that the mainloop makes everything seem more clean..




    4: The Finished Script

    Alrighty! We have done it! We have finished our script! Its not perfect, but it definitely gets the job done!

    Your final script should look like this:

    Simba Code:
    program scriptTemplate;

    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := '';
        password := '';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;

    procedure walkToCabbies();
    var
      pathToCabbies: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToCabbies := [Point(215, 172), Point(203, 172), Point(189, 167), Point(173, 165), Point(165, 159), Point(154, 150), Point(140, 139), Point(140, 124), Point(133, 120), Point(126, 114), Point(119, 109), Point(104, 107)];

      if SPS.walkPath(pathToCabbies) then
        minimap.waitPlayerMoving()
      else
        writeln('Failed Walk to Cabbies...');
    end;

    procedure walkToBank();
    var
      pathToBank: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToBank := [Point(104, 107), Point(119, 109), Point(126, 114), Point(133, 120), Point(140, 124), Point(140, 139), Point(154, 150), Point(165, 159), Point(173, 165), Point(189, 167), Point(203, 172), Point(215, 172)];

      if SPS.walkPath(pathToBank) then
        minimap.waitPlayerMoving()
      else
        writeln('Failed Walk to Bank...');
    end;

    procedure clickCabbies();
    var
      x, y: integer;
    begin
      if not isLoggedIn() then
        exit;

        mainscreen.findObject(x, y, 2602604, 19, colorSetting(2, 0.23, 0.88), mainscreen.playerPoint, 5, 5, 5, ['abbage'], MOUSE_LEFT);
        wait(randomrange(2000,3500));
        minimap.waitPlayerMoving();
    end;

    procedure bank();
    begin
      if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
        wait(randomrange(1500,2500))
      else
      begin
        writeln('Did not open bank. We failed. Termination in progress.');
        Terminatescript;
      end;
    end;

    procedure depositLoot();
    begin
    if bankScreen.isOpen() then
      begin
        bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
        wait(randomRange(1000, 2000));
        bankScreen.close();
      end else
      begin
        writeLn('Couldn''t find the bank for some reason!');
        Terminatescript;
      end;
    end;

    procedure mainLoop();
    begin

      walkToBank;
      bank;
      depositLoot;
      walkToCabbies;

      repeat
        clickCabbies;
      until tabBackPack.isFull();

    end;

    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      SPS.setup('Lumby', RUNESCAPE_SURFACE);
      SPSanyangle := false;

      if not isLoggedIn() then        
      begin  
        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);
      end;

      repeat
        mainLoop();
      until false;
    end.

    You can always add some lines to split up the script to make it easier to read. So, it could look like this:

    Simba Code:
    program scriptTemplate;

    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files

    {------------------------------------------------------------------------------
    ---------------------------FILL IN SCRIPT HERE---------------------------------
    -------------------------------------------------------------------------------}


    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := '';
        password := '';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;

    {------------------------------------------------------------------------------
    -------------------------STOP FILLING IN SCRIPT HERE---------------------------
    -------------------------------------------------------------------------------}


    procedure walkToCabbies();
    var
      pathToCabbies: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToCabbies := [Point(215, 172), Point(203, 172), Point(189, 167), Point(173, 165), Point(165, 159), Point(154, 150), Point(140, 139), Point(140, 124), Point(133, 120), Point(126, 114), Point(119, 109), Point(104, 107)];

      if SPS.walkPath(pathToCabbies) then
        minimap.waitPlayerMoving()
      else
        writeln('Failed Walk to Cabbies...');
    end;

    {------------------------------------------------------------------------------}

    procedure walkToBank();
    var
      pathToBank: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToBank := [Point(104, 107), Point(119, 109), Point(126, 114), Point(133, 120), Point(140, 124), Point(140, 139), Point(154, 150), Point(165, 159), Point(173, 165), Point(189, 167), Point(203, 172), Point(215, 172)];

      if SPS.walkPath(pathToBank) then
        minimap.waitPlayerMoving()
      else
        writeln('Failed Walk to Bank...');
    end;

    {------------------------------------------------------------------------------}

    procedure clickCabbies();
    var
      x, y: integer;
    begin
      if not isLoggedIn() then
        exit;

        mainscreen.findObject(x, y, 2602604, 19, colorSetting(2, 0.23, 0.88), mainscreen.playerPoint, 5, 5, 5, ['abbage'], MOUSE_LEFT);
        wait(randomrange(2000,3500));
        minimap.waitPlayerMoving();
    end;

    {------------------------------------------------------------------------------}

    procedure bank();
    begin
      if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
        wait(randomrange(1500,2500))
      else
      begin
        writeln('Did not open bank. We failed. Termination in progress.');
        Terminatescript;
      end;
    end;

    {------------------------------------------------------------------------------}

    procedure depositLoot();
    begin
    if bankScreen.isOpen() then
      begin
        bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
        wait(randomRange(1000, 2000));
        bankScreen.close();
      end else
      begin
        writeLn('Couldn''t find the bank for some reason!');
        Terminatescript;
      end;
    end;

    {------------------------------------------------------------------------------}

    procedure mainLoop();
    begin

      walkToBank;
      bank;
      depositLoot;
      walkToCabbies;

      repeat
        clickCabbies;
      until tabBackPack.isFull();

    end;

    {------------------------------------------------------------------------------}

    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

      SPS.setup('Lumby', RUNESCAPE_SURFACE);
      SPSanyangle := false;

      if not isLoggedIn() then        
      begin  
        players[currentPlayer].login();
        exitTreasure();
        minimap.setAngle(MM_DIRECTION_NORTH);
        mainScreen.setAngle(MS_ANGLE_HIGH);
      end;

      repeat
        mainLoop();
      until false;
    end.

    If you run this, this will take your character from the bank, all the way to the cabbage patch, collect 'em cabbages and bank them.

    Give it a shot!





    5: Final Thoughts

    Well, congratz on your cabbage collecting script!

    My hopes are that you learned a bit from this tutorial and how a script should flow. As you can see, I started with the two SPS procedures at the top of my script. This is because I just wanted to get them out of the way.

    I have a couple of things that I would love to remind you of for when you go and begin to write your own scripts:
    - Always remember that a procedure/function number 1 cannot be called in procedure/function number 2 unless procedure/function 1 are above procedure/function 2.
    - You should always try to have a nice and neat script if you want to have people read through it and give you advice. This is especially useful for when you apply for members.
    - Even though this script does not have a break system or anti-ban system, it never hurts to add them yourself. Read through scripts to get a feel for how those work.
    - Mainloops are not always needed, but they help keep things neat.
    - The Include has a lot of built-in options for you to use. Do not ever hesitate to use them! They are there for a reason, and that reason is to make your life easier!

    Anyways, I hope you enjoyed the tutorial, and most of all, I hope you learned from it!

    If you have any questions, feel free to comment, PM, or add me on skype!

    If you have anything you wish me to fix,, notice something is missing, or notice a problem with the tutorial, once again, let me know using any of those three listed options.


    Anyways,

    Happy Botting!
    Last edited by StickToTheScript; 06-10-2015 at 02:54 PM. Reason: Updated!

  2. #2
    Join Date
    Dec 2011
    Posts
    2,134
    Mentioned
    218 Post(s)
    Quoted
    1063 Post(s)

  3. #3
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,144
    Mentioned
    25 Post(s)
    Quoted
    430 Post(s)

    Default

    Quote Originally Posted by Clarity View Post


    Looks excellent. Seems like a tutorial I would've used back in the day. Some people do indeed learn better by reverse-engineering templates and skeletons!
    Thanks for making this
    It was my pleasure! I love writing things like this!

  4. #4
    Join Date
    Mar 2012
    Posts
    126
    Mentioned
    4 Post(s)
    Quoted
    20 Post(s)

    Default

    Super pro sauce.

  5. #5
    Join Date
    Jun 2012
    Posts
    4,873
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by StickToTheScript View Post
    You see the other bank chest? It's much closer than the one you're using.

    Good tutorial.

  6. #6
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,144
    Mentioned
    25 Post(s)
    Quoted
    430 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    You see the other bank chest? It's much closer than the one you're using.

    Good tutorial.
    LOL. I know. My goal was to demonstrate walking to a point off of the screen.
    But thanks! I enjoyed it.

    Quote Originally Posted by Raiden702 View Post
    Super pro sauce.
    Lol. Never heard that one before.
    Last edited by StickToTheScript; 06-10-2015 at 04:26 AM.

  7. #7
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    936
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    Congrats on releasing a tutorial!


    Your depositLoot procedure could be made even faster by using bankScreen.clickButton as follows:

    Simba Code:
    procedure depositLoot();
    begin
      if bankScreen.isOpen() then
      begin
        // Configure which preset to use in the setup
        bankScreen.clickButton(PRESET_BUTTON)
        // where PRESET_BUTTON is a user setup constant
      end else
      begin
        writeLn('Couldn''t find the bank for some reason!');
        Terminatescript;
      end;
    end;

    It might be worth adding that to the tutorial to show how we can allow script users more customisation when using the script. For example, you could set whether to use quick deposit or a preset, and which preset to use.

    Great tutorial mate.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  8. #8
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,144
    Mentioned
    25 Post(s)
    Quoted
    430 Post(s)

    Default

    Quote Originally Posted by Incurable View Post
    Congrats on releasing a tutorial!


    Your depositLoot procedure could be made even faster by using bankScreen.clickButton as follows:

    Simba Code:
    procedure depositLoot();
    begin
      if bankScreen.isOpen() then
      begin
        // Configure which preset to use in the setup
        bankScreen.clickButton(PRESET_BUTTON)
        // where PRESET_BUTTON is a user setup constant
      end else
      begin
        writeLn('Couldn''t find the bank for some reason!');
        Terminatescript;
      end;
    end;

    It might be worth adding that to the tutorial to show how we can allow script users more customisation when using the script. For example, you could set whether to use quick deposit or a preset, and which preset to use.

    Great tutorial mate.
    Added! Mentioned you and all! Thanks for the idea!

  9. #9
    Join Date
    Aug 2010
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    Awesome tut for us noobs! Thanks very much.

  10. #10
    Join Date
    Apr 2015
    Location
    FireFox
    Posts
    528
    Mentioned
    10 Post(s)
    Quoted
    227 Post(s)

    Default

    Congratz on the tutorial! Always nice to have multiples because they all include different contents, which will benefit new learners greatly!
    Scripting with ogLib

  11. #11
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,144
    Mentioned
    25 Post(s)
    Quoted
    430 Post(s)

    Default

    Quote Originally Posted by R3LAX View Post
    Awesome tut for us noobs! Thanks very much.
    Always a pleasure to help!

    Quote Originally Posted by indirectMW View Post
    Congratz on the tutorial! Always nice to have multiples because they all include different contents, which will benefit new learners greatly!
    Thanks! Always a pleasure helping in anyway I can.

  12. #12
    Join Date
    Mar 2013
    Location
    Argentina
    Posts
    751
    Mentioned
    27 Post(s)
    Quoted
    365 Post(s)

    Default

    I had a script for this, now you're going to totally ruin my earnings! damn dude..

    Great tutorial!
    Formerly known as Undorak7

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

  14. #14
    Join Date
    Jun 2015
    Posts
    69
    Mentioned
    0 Post(s)
    Quoted
    23 Post(s)

    Default

    A really nice, up to date guide! Thank you!

  15. #15
    Join Date
    Sep 2006
    Posts
    95
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    Useful, thanks for this

  16. #16
    Join Date
    Jul 2015
    Location
    AZ
    Posts
    103
    Mentioned
    2 Post(s)
    Quoted
    56 Post(s)

    Default

    Definitely going to be using this. I had already read through The Mayor's tutorial but couldn't seem to figure out SPS until I read this one. Once again, thank you for helping me release my first script!

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

    Default

    Quote Originally Posted by Clarity View Post


    Looks excellent. Seems like a tutorial I would've used back in the day. Some people do indeed learn better by reverse-engineering templates and skeletons!
    Thanks for making this
    I remember when I made an astral script. Yes I did modify and read some other users script to understand how it all fits together. And yes, it was pretty bad (My script.) The reverse engineering was such a help I wouldn't know where I'd be without it, although I remember having difficulties with colours because the island is dull.

  18. #18
    Join Date
    Oct 2014
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Very nice tutorial, basically I could change the base code a bit and for example, make the player pick wheat instead of cabbages and bank in another place, right?

  19. #19
    Join Date
    Sep 2015
    Posts
    65
    Mentioned
    7 Post(s)
    Quoted
    20 Post(s)

    Default

    Quote Originally Posted by karu View Post
    Very nice tutorial, basically I could change the base code a bit and for example, make the player pick wheat instead of cabbages and bank in another place, right?
    Yea. With the final script that @StickToTheScript posted, you could use it to find anything and pick it up. You just need to switch the SPS map, the coords, the bank, and the colours.

  20. #20
    Join Date
    Oct 2014
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by Shield View Post
    Yea. With the final script that @StickToTheScript posted, you could use it to find anything and pick it up. You just need to switch the SPS map, the coords, the bank, and the colours.
    This is great, thanks for the info

  21. #21
    Join Date
    Nov 2015
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by StickToTheScript View Post
    I have a couple of things that I would love to remind you of for when you go and begin to write your own scripts:
    - Always remember that a procedure/function number 1 cannot be called in procedure/function number 2 unless procedure/function 1 are above procedure/function 2.
    Note: That is not completely true, or at least not in the sense that is implied there. In Pascal and Delphi, the forward keyword allows you to declare that a function exists, and subsequently use it before actually implementing it.
    This is absolutely necessary in any language that aspires to support mutual recursion.
    Here's a dumb example of how the keyword may be used:

    Code:
    program new;
    
    function mystery(s:integer):integer; forward;
    
    procedure something(s:integer);
    begin
    writeln(mystery(s));
    end;
    
    function mystery(s: integer):integer;
    begin
    result:=s+5;
    end;
    
    
    begin
    something(5);
    end.

  22. #22
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,144
    Mentioned
    25 Post(s)
    Quoted
    430 Post(s)

    Default

    Quote Originally Posted by qnzr3 View Post
    Note: That is not completely true, or at least not in the sense that is implied there. In Pascal and Delphi, the forward keyword allows you to declare that a function exists, and subsequently use it before actually implementing it.
    This is absolutely necessary in any language that aspires to support mutual recursion.
    Here's a dumb example of how the keyword may be used:

    Code:
    program new;
    
    function mystery(s:integer):integer; forward;
    
    procedure something(s:integer);
    begin
    writeln(mystery(s));
    end;
    
    function mystery(s: integer):integer;
    begin
    result:=s+5;
    end;
    
    
    begin
    something(5);
    end.
    This is correct, but this tutorial is for beginners. Therefore, my goal was to not confuse them by the use of forward, so I had left it out all together.

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
  •