Results 1 to 10 of 10

Thread: Making A Setup Procedure

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

    Default Making A Setup Procedure

    Making A Setup Procedure
    By: StickToTheScript


    Intro

    Hello, everyone.

    Today, I will be showing you how to write a setup for a script. We will learn how to login the player, exit the squeal of fortune, open or close the Action Bar, XP Bar, Money Pouch, and even turn on your character's run.


    Before We Start

    Before we start, let's make sure we have the basic default script.

    Copy and paste this into Simba.

    Simba Code:
    program new;
    {$DEFINE SMART8} //I have SMART8 installed. If you dont, remove the '8'. If you dont know, open press play and if you get a SMART PARAMS error, then you have 7.2. XD
    {$i srl/srl.simba}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      Players[0].Active := True; // Set to true if you want to use Player 0
    end;

    begin
    end.

    Then, go to file and select "Save As Default"

    Now that you have your basic script ready, let's get started.



    Basics of the Procedure

    Ok. To start, we will want to create a procedure by the name of "setup".

    You should have this:

    Simba Code:
    procedure Setup;
    begin

    end;

    This is the procedure that you will be making your setup run in!


    The first thing we will want to do is place the following in the beginning of the setup.

    Simba Code:
    SetupSRL;
      DeclarePlayers;
      LoginPlayer;


    These are the basics of the setup. The first one, "SetupSRL", is what you call in order to be able to use the SRL Include. "DeclarePlayers" calls the procedure named "DeclarePlayers", which you copied and pasted earlier. Then, you have "LoginPlayer" which is a procedure that allows you to login your player.

    So, you should have a script that looks like this:

    Simba Code:
    program new;
    {$DEFINE SMART8} //I have SMART8 installed. If you dont, remove the '8'. If you dont know, open press play and if you get a SMART PARAMS error, then you have 7.2. XD
    {$i srl/srl.simba}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      Players[0].Active := True; // Set to true if you want to use Player 0
    end;

    procedure Setup;
    begin
      SetupSRL;
      DeclarePlayers;
      CheckSRLStats;
      LoginPlayer;  
    end;

    begin
    end.


    The Message

    So, a lot of people tend to put a welcome message at the beginning of their script. This will show you how.

    First off, you will want to know how to use Writeln. To properly use it, all you have to do is write:

    Simba Code:
    Writeln('');

    Do notice the brackets and apostrophe? Inside the apostrophe you write your message you wish to display. So, we will write the following in our setup procedure:

    Simba Code:
    Writeln('');
      Writeln('You''re reading StickToTheScript''s tutorial on Setups!');
      Writeln('Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('Thanks!');
      Writeln('');

    So, as you see, i have the "Writeln('');" at the top and the bottom of the main text. This allows it to be paragraphed. It is just like pressing enter; it gives you a blank line.

    So, if you were to run this, your debug box should say:

    Code:
    You're reading StickToTheScript's tutorial on Setups!
    Please report anything on the thread along with anything else you wish to say! XD
    Thanks!
    So, all together, your script should show:

    Simba Code:
    program new;
    {$DEFINE SMART} //I have SMART8 installed. If you dont, remove the '8'. If you dont know, open press play and if you get a SMART PARAMS error, then you have 7.2. XD
    {$i srl/srl.simba}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      Players[0].Active := True; // Set to true if you want to use Player 0
    end;

    procedure Setup;
    begin
      SetupSRL;

      Writeln('');
      Writeln('You''re reading StickToTheScript''s tutorial on Setups!');
      Writeln('Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('Thanks!');
      Writeln('');

      DeclarePlayers;
      LoginPlayer;
    end;

    begin
      setup;
    end.

    Notice that I have the setup in between the last begin and end? That lets the script run the setup procedure.

    Now, your script will display a message, then login, and then your script will end. So, now all you need to do it take this and put it in your script.


    The Extras

    Now, there are a lot of extra things that people like to use in their setups. In this case, I will show you how to Exit the squeal of fortune, open or close the action bar, the xp bar, money pouch, and turn on your run.


    Squeal Of Fortune

    Ok. So, we start with exiting the squeal of fortune. To do this, all you need to add is this:

    Simba Code:
    ExitSquealofFortune;

    Simple, right? Yes and the following are simple as well.


    Action Bar

    The action bar is primarily used for Combat (So definitely attempt to use it for your combat scripts) but is also used for other simple and basic skills. You can use it for dropping, eating, etc.
    For the action bar you will also want to put in a single line of code that looks like this:

    Simba Code:
    ToggleActionBar(False);

    This should also appear fairly simple. You are toggling the action bar. When the word in the brackets is false, then the action bar will be closed. If the word is true, then the action bar will be opened. Get it? XD


    XP Bar

    The XP bar keeps track of your XP Gain while you train a skill. For the XP Bar, it is roughly the same as the Action bar. You will want to use the following:

    Simba Code:
    ToggleXPBar(True);

    Again, the True means that the XP bar is open. False means the XP bar is closed.


    Money Pouch

    Your Money Pouch is primarily used to hold your coins. You can use it to track how many GP's you picked up or just to view the amount of money you have.
    For this, you will want to write this:

    Simba Code:
    ToggleMoneyPouch(False);

    And yes, the True means that the Money Pouch is open and False means the Money Pouch is closed.


    Turn On Run

    Turning on your run allows the player to run. The following is a very simple, built-in way of toggling it.
    First you would want to write:

    Simba Code:
    SetRun(True);

    This allows you to set your run on. True = On. False = Off.


    So, all together your script should now look like this:

    Simba Code:
    program new;
    {$DEFINE SMART} //I have SMART8 installed. If you dont, remove the '8'. If you dont know, open press play and if you get a SMART PARAMS error, then you have 7.2. XD
    {$i srl/srl.simba}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      Players[0].Active := True; // Set to true if you want to use Player 0
    end;

    procedure Setup;
    begin
      SetupSRL;

      Writeln('');
      Writeln('You''re reading StickToTheScript''s tutorial on Setups!');
      Writeln('Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('Thanks!');
      Writeln('');

      DeclarePlayers;
      LoginPlayer;

      ExitSquealofFortune;
      ToggleActionBar(False);
      ToggleXPBar(True);
      ToggleMoneyPouch(False);
      SetRun(True);
    end;

    begin
      setup;
    end.


    And that should be the very basics of it. The script will now print the message, login, exit the squeal of fortune, make sure the action bar is closed, make sure the XP bar is open, make sure the money pouch is closed and have your run on. Then, the script should terminate.


    Conclusion

    So, now you have the basic idea of how to write a setup in your scripts.

    If you wanted, you could always have other setup procedures in your script that you could call. These would consist of loading DTMs, Bitmaps, SPS setup, XP Counters, Change the angle of camera, face the camera in a certain direction, etc.

    So, there you go!

    Hope that this has helped in one way or another.
    Please let me know if there is a typo that you came across, or any issues with the coding. I will happily fix those. XD
    If there is anything else that should be added, please let me know!
    Feel free to also Comment, +Rep, or do whatever you want! XD

    Thanks!

    StickToTheScript

  2. #2
    Join Date
    Oct 2012
    Posts
    84
    Mentioned
    0 Post(s)
    Quoted
    41 Post(s)

    Default

    "Please let me know if there is a typo that you came across"

    'Your' should be 'You're'

    Thanks for this guide though, just starting to learn scripting and it helped me

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

    Default

    Quote Originally Posted by BeRy View Post
    "Please let me know if there is a typo that you came across"

    'Your' should be 'You're'

    Thanks for this guide though, just starting to learn scripting and it helped me
    Thanks man! I always seem to do that! Hope this helped!

  4. #4
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Ignore 90% of what Runehack just said... He's just being a grammar nazi and he's not even correct about some of his "corrections".

    Good job on this and I hope it helps people out! +Rep

  5. #5
    Join Date
    Dec 2012
    Location
    Denver
    Posts
    16
    Mentioned
    2 Post(s)
    Quoted
    12 Post(s)

    Default

    Wow thanks for this.

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

  7. #7
    Join Date
    Mar 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    I appreciate this as well, thanks Stick!

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

    Default

    Quote Originally Posted by tiredofcrap View Post
    I appreciate this as well, thanks Stick!
    You are very welcome! If you need any extra help, feel free to let me know! I am more than happy to help!

  9. #9
    Join Date
    Apr 2012
    Location
    Land of the Rising Sun
    Posts
    207
    Mentioned
    0 Post(s)
    Quoted
    77 Post(s)

    Default

    Nice simple but useful guide. I wish I had read something like this when I first started scripting!

    This line here wouldn't run though, cause you have closed off the write line with the ' 'in you're' (Notice how it ends early, and all the other WriteLns below it are blue).

    Simba Code:
    Writeln('');
      Writeln('You're reading StickToTheScript''s tutorial on Setups!');
      Writeln('
    Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('
    Thanks!');
      Writeln('
    ');

    I think it should read:

    Simba Code:
    Writeln('');
      Writeln('You''re reading StickToTheScript''s tutorial on Setups!');
      Writeln('Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('Thanks!');
      Writeln('');
    My Scripts: DWT Iron Miner

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

    Default

    Quote Originally Posted by pure_thief View Post
    Nice simple but useful guide. I wish I had read something like this when I first started scripting!

    This line here wouldn't run though, cause you have closed off the write line with the ' 'in you're' (Notice how it ends early, and all the other WriteLns below it are blue).

    Simba Code:
    Writeln('');
      Writeln('You're reading StickToTheScript''s tutorial on Setups!');
      Writeln('
    Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('
    Thanks!');
      Writeln('
    ');

    I think it should read:

    Simba Code:
    Writeln('');
      Writeln('You''re reading StickToTheScript''s tutorial on Setups!');
      Writeln('Please report anything on the thread along with anything else you wish to say! XD');
      Writeln('Thanks!');
      Writeln('');

    Thanks for pointing that out! I cant believe I missed that. :P

    I will fix that right now!

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
  •