.: Getting Prepared for SCAR/SRL :.
-A Sebo Thread.
IF YOU VOTE NO, EXPLAIN WHY, OR I WILL COUNT IT AS SPAM
Note: Please post suggestions on what to do better, or what to add. It will make this tutorial even better.
Note: this is a pretty big tutorial, and it involves ALOT of reading, but donot give up! Of course, I cannot teach you every command, because there are sooooo many, but, the more the merrier, and hopefully, when you finish reading this, you will have a good understanding of how things work.
Please, go easy on me as this is my first tutorial, I might miss a few things, and if my spelling/grammer is off, it's because I came from Poland, and was in America for only a few years. 
I got a question for some people out there...
How many people think it is intimidating to see how the "uber long cool Scripts"
are made?
*a few people raise their hands*
Well thats pretty much the way I felt when I started scripting, but the truth is, don't be, because soon, when you make great scripts, other people will look at your script and say. "Dang, that is so hard, I'm never going to attempt scripting." and maybe even, you can help them out by reading this Tutorial.
I am going to teach you the basics, so you can get a feel on how things work.
Chapter One-
The Very Basics:
What you are going to learn in this Chapter:
-Adding an Include.
-How to find a Color.
-Moving and clicking the mouse.
-Understanding Constants.
-Understanding Variables.
-Using Constants + Variables.
-Using Repeats.
-Using Procedures.
These are the basic commands at SRL, they are used in every/almost every script, and you will need to learn how they work.
Includes:
Includes are what fuels SCAR, without it, SCAR is basically going nowhere.
You need Includes at the very beginning of your script:
SCAR Code:
program new;
{.include SRL/SRL.scar}
begin
end.
what this does: it tells SCAR to use the file SRL.scar from your includes file, so you can have different procedures/functions etc.
remember: once you add this include you need to put SetupSRL; in your Main loop.
that simply calls it to setup everything in SRL for your script.
FindColor/FindColorTolerance:
SCAR Code:
FindColorTolerance(x, y, color, xs, ys, xe, ye, Tolerance);
whoa, what does all that mean?
- x, y : when you drag your crosshair onto the screen, that is where it is going to look for.
- color : That is the color it will look for. eg. 352633
- xs, ys, xe, ye : This is the Coordinates of the screen. Where is will look for the colors.
- Tolerance : This will look for similar colors, eg. black is 0, if I put tolerance for 10, it will look for similar colors to black like 63445.
Same thing goes for FindColor, except it's without the tolerance.
Mouse:
Mouse was very weird for me when I first began, I didn't understand it with all the RandX stuff. but thats why im here to teach you! 
SCAR Code:
Mouse(mousex, mousey, ranx, rany, left);
wut?
Ok, here is what all this means:
- mousex : The x coordinate to click.
- mousey : the y coordinate to click.
- ranx & rany : how many pixels it will randomly move when moving the mouse.
- left : True or False, True means Left Click, False means Right Click.
Pretty simple right? and you thought it looked confusing..
const:
ahh.... constants, one of my favorite things in SCAR.
these are so simple! I don't know how, but I had errors putting them in my script.
SCAR Code:
const
Username = 'monkey';
Const means Constant, this will stay the same throughout the whole script. You always have to put this before any procedure, but after a Variable.
these can be used to type things, for example, usernames and passwords.
like this:
pretty simple eh?
Var:
Var = Variable
A variable is something that Varies, eg. thats where the name comes from.
Variable usually never stay the same. Like numbers going up.
SCAR Code:
Var
howmanytimesamigoingtodothis : integer;
now, howmanytimesamigoingtodothis is my variable. It will change throughout the script.
I can use it for lots of things, for example, keeping track on how many times I did something, hence the name of the variable : howmanytimesamigoingtodothis. but don't get me wrong, variable can do much more, just I'm not going to be able to explain everything to you.
this is how I would use it in a script: (My variable name is Chopped.)
SCAR Code:
begin
choptree;
Chopped := Chopped + 1;
end.
it is telling SCAR, that I chopped the tree 1 more time.
now lets move on to something more complicated like repeats...
Repeats:
Repeats are what most scripts need, ortherwise, they would do 1 thing and the script would be done. This is where Constants and Variables also come in handy, because you don't want to repeat something forever, or do you...?
SCAR Code:
Var
thismanytimes : Integer;
Const
Sayit = 5;
begin
repeat
writeln('test');
wait(100);
thismanytimes := thismanytimes + 1;
until(sayit = thismanytimes);
end.
this is telling SCAR to repeat itself _ times from the const.
wow! if you made it this far, you are doing GREAT! congratulate yourself.
Procedures:
Procedures are what break up scripts into sections, so it is easier to read, and if you put important procedures on top of normal ones, you can call that procedure into the not so important procedure. (May seem confusing, but read it carefully.)
Ex.
SCAR Code:
procedure ImportantProcedure;
begin //you need begin, other wise it wont tell the procedure to begin.
DoImportantStuff; //this is not a actual command, but I use it for an ex.
end.
procedure SomeotherProcedure;
begin
Dothis;
ImportantProcedure; //I called the procedure from earlier on in the script, so I can use it.
end.
see? Easy.
ok, so we know the basics, we learned how to:
- Find a color.
- Move and Click the Mouse.
- Learned what constants are.
- Learned what Variable's are
- Learned how to repeat correctly.
- Learned to add includes.
- Learned how to use procedures.
wow, so much stuff in so little time!
see, scripting isn't as hard as it looks.
"but what about things like findcolortolerancespiral?"
well, those things are simple, just take them apart, and work with it step by step.
Chapter 2-
Making a simple script:
Ok, now that you understand some of the basics, we can use this knowledge to put together a simple script.
So open up SCAR, and you should see this.
Make the program name Tutorial or something like that. Or you can completely delete it, if you want.
Ok, now what you want to do is add some spaces between program and begin, so you can add some "beef" to the script.
Ok, before you do anything. Add {.include SRL/SRL.scar} under program
and in your main loop(the one at the very bottom) add SetupSRL;
As we know, this calls to use SRL in our script.
Now that we have spaces, we can add some Consts, and Variables.
I will be making a woodcutting script for an example.
Ok, lets add our constants, lets make it for tree colors.
make the constants like TreeCol1 = 54365954; TreeCol2 etc...
So now our script should look like this...
SCAR Code:
program TuT;
{.include SRL/SRL.scar}
Var
x, y : integer; //These are our Variables. x, y : for Colors.
const //this calls our Constant.
TreeCol1 = 5500; //One Tree Color (Not real)
TreeCol2 = 5655; //Another Tree Color (Not real)
Loads = 5; //how many loads should the script do (will use later on.)
begin //our main loop.
SetupSRL; //we setup SRL in the main loop, before anything else.
end. // end of the script.
So we added some constants and a Variable x, y which is for colors. Since SCAR sometimes will give an error when not adding it to a constant.
Ok, lets add a variable to Total Loads done, we can add it as TLoads.
and we can make room for adding the woodcutting procedure.
Quick Tut with if's and then's, If and Thens are really important.
You can use them like if (FindColor(Colorstuff)) then. pretty simple, it is really straight forward.
So our script should look somewhat like this.
SCAR Code:
program TuT;
{.include SRL/SRL.scar}
Var
x, y, TLoads : integer; //We added TLoads, where x, y, is because it is a Variable.
//it will be called later on the script.
const
TreeCol1 = 5500;
TreeCol2 = 5655;
Loads = 5;
Procedure LookForColors; //Our new procedure.
begin
if not LoggedIn then Exit; // A simple FailSafe. I will explain a bit later. EDIT: forgot not :D
repeat //We are going to repeat this, as it is the most important procedure.
if (FindColorTolerance(x, y, TreeCol1, MSX1, MSY1, MSX2, MSY2, 5)) then //notice, we used our constant. I will explain MS stuff.
Mouse(x, y, 2, 3, True); //Ok, it tells SCAR, if it found the color, then it will move the mouse to those coordinates.
Wait(3000);
Until InvFull; or (TLoads = Loads) //Telling it to repeat itself, until the inventory is full. or until The total loads = The Loads you set in the constants.
If InvFull Then
TLoads := TLoads + 1; //Telling SCAR that it did 1 load.
DropTo(2, 28); //Tells SCAR to drop the logs from inventory spots 2-28.
end; //we need a semicolon, because it tells the script, it's ending a PROCEDURE.
begin
SetupSRL;
LookForColors;
end.
Ok, as I said I will explain some stuff in the script.
Failsafes:
These are really important, without them, your script might be doing what you dont want it to do endlessly, and JaGeX will catch on, and your account would be dead.
The most simple one is If not LoggedIn then Exit;
It is telling the script, if you are already LoggedIn, then it will log you out.
This is needed for MultiPlayer, but since I'm not going through that, it is not needed for this script.
MSX1, MSY1 etc :
This is really simple, it is telling SCAR to look for things in a certain place, instead of using all these coordinates, you can use some stuff built in SRL.
MS = MainScreen
So, the X1, is the First X coordinate
Here is the list that I know on the MS stuff
MS = MainScreen
MM = MiniMap
MC = MainChat
MI = MainInventory
Congratulations! You have created your First basic Script! Dang!, now you only need multiplayer, and antirandoms, and your on your way to amazing things in life.