PDA

View Full Version : Making A Setup Procedure



StickToTheScript
04-29-2013, 03:48 PM
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.

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:

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.


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:

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:

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:

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:




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:

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:

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:

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:

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:

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:

SetRun(True);

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


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

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

BeRy
05-09-2013, 06:30 PM
"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 :)

StickToTheScript
05-17-2013, 05:01 AM
"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! :D

Kevin
05-17-2013, 10:02 PM
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

Plawkx
05-18-2013, 08:24 PM
Wow thanks for this.

StickToTheScript
05-18-2013, 09:30 PM
Wow thanks for this.

Your welcome! Hope it helps you out! :P

SLEEPER
06-19-2013, 04:58 AM
I appreciate this as well, thanks Stick!

StickToTheScript
06-19-2013, 05:36 AM
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! :D

Thief
06-19-2013, 12:17 PM
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).

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:

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('');

StickToTheScript
06-19-2013, 01:21 PM
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).

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:

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! :D