SRL Archive - OSR Beginner Scripting Tutorials

Making your first Script!


Striken

2012-06-17 19:40:07

Alright, today I'm going to explain and show you how to make your very first script! This may not be the best guide but it'll still be helpful. I'm not the best at writing tutorials so I hope you can understand that after reading this :)

Contents
1. What can a Script do?
2. How do I make a Script?
3. Explanation
4. Antiban, Randoms, Errors
5. Conclusion

What can a Script do?
First off a Script can do almost any task that can be accomplished in any event with dedication put into it. This is useful to have your character progressed while you are out having fun and able to have fun with your game character.

How do I make a Script?

Lets start off with defining SRL, SPS, and SMART.
Program BasicScriptTutorial;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
Now what this does is it has Smart loaded up and has SRL in order to accomplish your tasks. SPS stands for SRL.Positioning.System which allows your character to be moving around the world of RuneScape.

Now we'll be setting up our player form which will allow us to have the script login your account and choose a world that you desire it to be on.
const
{==========Smart Setup==========}
World = 0; // Input the runescape world number right here for it to select. You may leave it as 0 if you would like it to select a random world.
MEMBERS = False; // Select False if you are not a member. Select True if you are a member.
SIGNED = True; // Select True if you are using single account. Select False if not.
{===============================}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //Your Runescape username goes right here.
Players[0].Pass := ''; //Your Runescape password goes right here.
Players[0].Active := True; //Set to True if you want to use this player. Set to False to disable this player.
Players[0].Pin := ''; //Put your Bank PIN here. Leave blank if you don't have a Bank PIN.
end;

Explination
Now that we have that done we'll be making our script being able to mine and do various things. But for this we'll just be doing the basics to mining.

procedure MineTin;
var x, y: integer;
What that has just done is it has made a procedure for our task to be completed. Next we'll have it search for a specific color that corresponds to a certain uptext that we'll be entering.

procedure MineTin;
var x, y: integer;
begin
if FindObj(x, y, 'in' COLOR, 10) then //This will have the script find an object of your choice
begin
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000)); // This will make the script wait for a certain time
until (InvFull);
end;
Now this is just a basic procedure for mining tin but I have not given you the color as we'll have to get that ourselves. You'll have noticed that I have written "end;" which will end that procedure if your inventory is full. Now onto Color finding.

Now we'll be selecting our own and color and how this is down is by using the "Pick a colour" tool. Now you will have to click on that tool and select the color you would want.

Now that we have the Color we'll be replacing the "COLOR" text with our color we have selected.
procedure MineTin;
var x, y: integer;
begin
if FindObj(x, y, 'in' 10658473, 10) then //This will have the script find an object of your choice
begin
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000)); // This will make the script wait for a certain time
until (InvFull);
end;

You'll notice that there is a 10 after the color and that my friend is Tolerance. I usually set my Tolerance to 10 for my script to work efiiciently but you can alter it to your liking.

Okay so we're able to make our script to mine but it will only do this once and that's it. The next thing we would want to do is to make it walk to the bank and walk back efficiently. Now I know what your thinking "god this is hard" but really it's not. It's pretty simple to do it if you have done it multiple times and got the hang of it. First you will want to download this tool.

Wolygon's Path Creator : http://villavu.com/forum/showthread.php?t=64891&highlight=path

Once you have downloaded it you will want to open it up and click new image and hover to
C:\Simba\Includes\SPS\img\runescape_surface\runesc ape_surface.png and browse to a certain area.

You'll want to click the points to a path in which you want your script to walk to. After that is done click the box that has the text of "Click to generate" and you'll be giving some text. You may want to copy and paste this onto notepad. You are also given the SPS Area and in this case I was given 11_7. Keep that number in mind or in notepad.

procedure WalkToBank;
begin
if (InvFull) then
begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['11_7']);
ToBank := [Point(4566, 3145), Point(4566, 3136), Point(4558, 3129),
Point(4551, 3120), Point(4545, 3109), Point(4532, 3095), Point(4519, 3070),
Point(4519, 3061), Point(4521, 3038), Point(4518, 3010), Point(4518, 2997),
Point(4518, 2981), Point(4521, 2953), Point(4525, 2940), Point(4541, 2940),
Point(4555, 2937), Point(4569, 2933), Point(4581, 2929), Point(4579, 2910),
Point(4577, 2903)];
SPS_WalkPath(ToBank);
end;

This is what you would want to have in order to make it walk. Now this just walks to the bank and stands there. Now we would want to make it bank. Now we're at Varrock West Bank so we will be using the following 'vwb' as our bank fuction.

More information about banking over here : http://villavu.com/forum/showthread.php?t=57105

procedure BankTin;
begin
WriteLn('Looking for bank.'); // Writes in the Debug Box
if FindBank('vwb') then // Finds the bank
begin
WriteLn('We have found the bank.');
if OpenBank('vwb', False, True) then // Opens the bank
begin
WriteLn('Proceeding to bank Tin');
DepositAll; // Deposits All items in Inventory
CloseBank; // Closes the bankscreen
WriteLn('Banking completed. Proceeding to Rest.');
RestUntil(100); // Rests character
end;
end;
end;

Now that we have the banking done I'm going to be introducing Antibans, Randoms, and Errors.

Antiban, Randoms, Errors
I'm sure I know what your thinking. "What is Antiban?" Well, glad you asked! Antiban is a way of making your script do something while it mines or chops or any type of task to look like someone who is legit but sometimes antiban can be a little obvious.

procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8) of
0:
begin
HoverSkill('Mining', false);
wait(1500+Random(250));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(25+random(150));
MakeCompass('S');
wait(75+Random(150));
MakeCompass('N');
end;
end;
end;

Here I have put in a very simple Antiban for all you out there. It's just a basic one so dont go around thinking it'll be the best. Now Randoms are pretty simple. You will just have to incorporate "FindNormalRandoms;" in your procedures so that it will detect Random events most of the time. Now, lets compile our script shall we! Uh oh is right, since we just got an error message.

Program BasicScriptTutorial;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

Var
WalkToBank:TPointArray;

const
{==========Smart Setup==========}
World = 0; // Input the runescape world number right here for it to select.You may leave it as 0 if you
would like it to select a random world.
MEMBERS = False; // Select False if you are not a member. Select True if you are a member.
SIGNED = True; // Select True if you are using single account. Select False if not.
{===============================}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //Your Runescape username goes right here.
Players[0].Pass := ''; //Your Runescape password goes right here.
Players[0].Active := True; //Set to True if you want to use this player. Set to False to disable this player.
Players[0].Pin := ''; //Put your Bank PIN here. Leave blank if you don't have a Bank PIN.
end;
procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8) of
0:
begin
HoverSkill('Mining', false);
wait(1500+Random(250));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(25+random(150));
MakeCompass('S');
wait(75+Random(150));
MakeCompass('N');
end;
end;
end;
procedure MineTin;
var x, y: integer;
begin
repeat
FindNormalRandoms;
WriteLn('Looking for Tin to Mine.');
if FindObj(x, y, 'in', 8421770, 10) then //This will have the script find an object of your choice
begin
WriteLn('Mining Tin.');
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000));
AntiBan;
until (InvFull);
end;
end;
procedure WalkToTheBank;
begin
if (InvFull) then
begin
FindNormalRandoms;
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['11_7']);
WalkToBank := [Point(4566, 3145), Point(4566, 3136), Point(4558, 3129),
Point(4551, 3120), Point(4545, 3109), Point(4532, 3095), Point(4519, 3070),
Point(4519, 3061), Point(4521, 3038), Point(4518, 3010), Point(4518, 2997),
Point(4518, 2981), Point(4521, 2953), Point(4525, 2940), Point(4541, 2940),
Point(4555, 2937), Point(4569, 2933), Point(4581, 2929), Point(4579, 2910),
Point(4577, 2903)];
SPS_WalkPath(WalkToBank);
end;
procedure BankTin;
begin
FindNormalRandoms;
WriteLn('Looking for bank.');
if FindBank('vwb') then
WriteLn('We have found the bank.');
if OpenBank('vwb', False, True) then
WriteLn('Proceeding to bank Tin');
DepositAll;
CloseBank;
WriteLn('Banking completed. Proceeding to Rest.');
RestUntil(100);
AntiBan;
end;
begin
Smart_Server := WORLD; //This here sets up the SMART Minimizing Autoing Resource Thing so you can bot.
Smart_Members := MEMBERS;
Smart_Signed := SIGNED;
Smart_SuperDetail := False;
SetupSRL; //This here sets up SRL incase you didn't know.

DeclarePlayers; //This here is so the script knows that the player info is filled in with.
LoginPlayer; //This here logs in your player you filled in with.

repeat
MineTin;
WalkToTheBank;
BankTin;
until AllPlayersInactive;
end.

Message : [Error] (77:1): Identifier expected at line 76
Compiling failed.

Now line 76 is right before "Procedure BankTin;" and the reason we got an error is because if your script has for an example in this script.
if (InvFull) then
begin
FindNormalRandoms;
You must then put another "end;" at the end of that procedure for every "begin" that you have in that procedure in order for that error to go away.

Now this is our final result with this tutorial. This script just mines Tin at Varrock West and banks at Varrock West Bank. Your allowed to edit it if you want but dont go around taking credit for work you didn't do.

Program BasicScriptTutorial;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

Var
WalkToBank:TPointArray;

const
{==========Smart Setup==========}
World = 0; // Input the runescape world number right here for it to select. You may leave it as 0 if you would like it to select a random world.
MEMBERS = False; // Select False if you are not a member. Select True if you are a member.
SIGNED = True; // Select True if you are using single account. Select False if not.
{===============================}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //Your Runescape username goes right here.
Players[0].Pass := ''; //Your Runescape password goes right here.
Players[0].Active := True; //Set to True if you want to use this player. Set to False to disable this player.
Players[0].Pin := ''; //Put your Bank PIN here. Leave blank if you don't have a Bank PIN.
end;
procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8) of
0:
begin
HoverSkill('Mining', false);
wait(1500+Random(250));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(25+random(150));
MakeCompass('S');
wait(75+Random(150));
MakeCompass('N');
end;
end;
end;
procedure MineTin;
var x, y: integer;
begin
repeat
FindNormalRandoms;
WriteLn('Looking for Tin to Mine.');
if FindObj(x, y, 'in', 8421770, 10) then //This will have the script find an object of your choice
WriteLn('Mining Tin.');
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000));
until (InvFull);
end;
procedure WalkToTheBank;
begin
if (InvFull) then
begin
FindNormalRandoms;
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['11_7']);
WalkToBank := [Point(4566, 3145), Point(4566, 3136), Point(4558, 3129),
Point(4551, 3120), Point(4545, 3109), Point(4532, 3095), Point(4519, 3070),
Point(4519, 3061), Point(4521, 3038), Point(4518, 3010), Point(4518, 2997),
Point(4518, 2981), Point(4521, 2953), Point(4525, 2940), Point(4541, 2940),
Point(4555, 2937), Point(4569, 2933), Point(4581, 2929), Point(4579, 2910),
Point(4577, 2903)];
SPS_WalkPath(WalkToBank);
end;
end;
procedure BankTin;
begin
FindNormalRandoms;
WriteLn('Looking for bank.');
if FindBank('vwb') then
WriteLn('We have found the bank.');
if OpenBank('vwb', False, True) then
WriteLn('Proceeding to bank Tin');
DepositAll;
CloseBank;
WriteLn('Banking completed. Proceeding to Rest.');
RestUntil(100);
AntiBan;
end;
begin
Smart_Server := WORLD; //This here sets up the SMART Minimizing Autoing Resource Thing so you can bot.
Smart_Members := MEMBERS;
Smart_Signed := SIGNED;
Smart_SuperDetail := False;
SetupSRL; //This here sets up SRL incase you didn't know.

DeclarePlayers; //This here is so the script knows that the player info is filled in with.
LoginPlayer; //This here logs in your player you filled in with.

repeat
MineTin;
WalkToTheBank;
BankTin;
until AllPlayersInactive;
end.

If you have read this from top to bottom thanks for paying attention. Leave any possible Feedback and Good Luck! :p

Abu

2012-06-18 12:01:44

Very nice tutorial.

A few suggestions:

- Make your images a tad bit smaller
- Make your headings bigger and coloured
- Run a spell check, you spell explanation and corresponds wrong
- Add in PixelShift so they can actually get this script working

Otherwise good job!

Striken

2012-06-18 12:32:23

From: abu_jwka
Very nice tutorial.

A few suggestions:

- Make your images a tad bit smaller
- Make your headings bigger and coloured
- Run a spell check, you spell explanation and corresponds wrong
- Add in PixelShift so they can actually get this script working

Otherwise good job!


Thanks for the advice. Not that good at writing scripting tutorials. First time writing one :)

Master BAW

2012-06-18 14:58:17

thanks :D

Striken

2012-06-20 20:48:25

Bump I guess…?

Striken

2012-06-22 03:01:58

Anyone have any feedback?

deanironman

2012-06-22 09:18:15

I always get 'Begin; error line 5 then when i type that it doesnt work

Striken

2012-06-22 11:39:32

From: deanironman
I always get 'Begin; error line 5 then when i type that it doesnt work


Write out your script for me so I know what you have so far.

NKN

2012-06-22 21:37:58

You do know it's not good to double post, right? (I.E, bumping)

Striken

2012-06-22 21:59:09

From: NKN
You do know it's not good to double post, right? (I.E, bumping)


I'm sorry :duh:

deanironman

2012-06-26 00:55:47

I gave up but ill try again. I want to make a lobster fishing script that drops them has antibann and solves every random can you help pleasee

Striken

2012-06-26 01:17:03

From: deanironman
I gave up but ill try again. I want to make a lobster fishing script that drops them has antibann and solves every random can you help pleasee


Implanting the random procedure will do the randoms that it is capable of doing which is what they have done. There may be some that wont work but most work. As for script you can change it up to your liking or even to the liking the script should be. Like from 'ine' to 'age'

Gucci

2012-06-26 01:17:55

Nicely done I just suggest working on your standards and also something I noticed when you use mouse(x, y, 0, 0, true) then you don't need choose option add that left clicks

Striken

2012-06-26 01:20:44

From: Gucci
Nicely done I just suggest working on your standards and also something I noticed when you use mouse(x, y, 0, 0, true) then you don't need choose option add that left clicks


Aimed for this to be a simple guide so I guess it makes some sense. If I had done more it would've been in intermediate section or something

deanironman

2012-06-26 12:34:05

How do I make the script just fish then drop then repeat

kazzos

2012-07-09 02:15:03

thanks for the tutorial, can't wait to get started!

Striken

2012-07-09 19:38:20

From: kazzos
thanks for the tutorial, can't wait to get started!


Well you'll get on the right track. :)

kilzrus

2012-07-11 15:46:22

i get this error
[Error] C:\Simba\Includes\sps/sps.simba(125:3): Unknown identifier 'sortTPAByX' at line 124


i just litterally copy and pasted yours to try it and still got it, because mine didn't work

NKN

2012-07-11 16:11:57

Update SPS

Striken

2012-07-11 17:39:42

From: kilzrus
i get this error
[Error] C:\Simba\Includes\sps/sps.simba(125:3): Unknown identifier 'sortTPAByX' at line 124


i just litterally copy and pasted yours to try it and still got it, because mine didn't work


As NKN said. Update SPS. Update SRL while your at it and check for updates everyday just to make sure on a daily basis.

kilzrus

2012-07-12 05:27:44

From: Phyaskou
As NKN said. Update SPS. Update SRL while your at it and check for updates everyday just to make sure on a daily basis.


Yeahh I updated it and it worked for some reason the first time I updated it didnt work

ninja112

2012-12-25 01:34:52

I Need a script for Auto typing.

DannyRS

2012-12-25 01:36:42

From: ninja112
Can you please post the script in one line?
cant understand wich one to copy


Then your not ready to use it ;) read the tut again in more detail

Gucci

2012-12-25 01:37:09

From: ninja112
Can you please post the script in one line?
cant understand wich one to copy


The finished script is at the bottom of the OP if that's what your asking

Alligaattor

2012-12-26 11:31:29

I do everything "right" but it doesn't walk… when i start the script it works for 2-3 steps and then not walking anymore. The walkpath is not the same tho, im trying it in different location.

DannyRS

2012-12-26 11:34:05

From: Alligaattor
I do everything "right" but it doesn't walk… when i start the script it works for 2-3 steps and then not walking anymore. The walkpath is not the same tho, im trying it in different location.


Are you in the same area as in the guide? The sps map you load needs to be for where you are,

Sps recently got updated maybe his guide points are outdated for that spot?

Gucci

2012-12-26 11:34:17

From: Alligaattor
I do everything "right" but it doesn't walk… when i start the script it works for 2-3 steps and then not walking anymore. The walkpath is not the same tho, im trying it in different location.


Probably because the maps have been updated

Alligaattor

2012-12-26 12:50:18

const
mm = mini map;

i just updated sps, srl, msi, plugins, extensions and simba itself. opened the creator, opened the surface map located the place i wanted it to walk clicked the pathpoints i want it to go, copypaste from the program to simba the code, made few edits to make it more userfriendly, my char is is right place and it clicks 1 time in the right place on mm, next it clicks on wrong place (up about about 5-10 pixel where my char is and it's suposed to click down) in mm and last click is right again but then stops…


Like i already said (not very clearly ("The walkpath is not the same tho, im trying it in different location."), im not in the same place as the guy who made this tutorial, i have the sps points for the location im in so that shouldn't be the problem.

tvain

2012-12-27 13:12:00

Pretty good man! Only thing I can think of right now is mention where we can get all the "methods". For example how to click on a NPC (if that's what you call them on srl) etc…

Striken

2012-12-30 02:49:30

From: DannyRS
Are you in the same area as in the guide? The sps map you load needs to be for where you are,

Sps recently got updated maybe his guide points are outdated for that spot?


I made this guide way before the EoC so I guess the maps were updated.

Dan the man

2013-03-14 19:32:42

Excellent tutorial mate. Great explanations and very easy to follow.

I had a question around banking though.

If I was wanting to bank all of a particular item, instead of clicking the bank all button, how would I do that?

This is mainly for the Old School Runescape servers, where the bank all hasn't been introduced yet.