SRL Archive - Outdated Tutorials

Getting used to Commands


Sebo

2007-11-22 23:26:36

.: 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:

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:

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

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.. :duh:

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. :spot:

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:
TypeSend(Username);

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.

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.)


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…? :redface:



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.

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.

program new;
begin
end.

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.

program Tut;


begin
end.

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…

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.

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.

HayHay89

2007-11-23 20:53:34

thanks,
i learnt heaps man
very easly explained
and your grammer was fine lol
this will help heaps of people including me
lol
this has made me 1 step closer to be a pro lol
any way keep up the good work
and keep writing tuts
:google: :f: :f: :google:

Sebo

2007-11-24 09:39:14

Thanks, I appriciate (spelling) comments like that :), I will be writing more tutorials for sure. :)

R0b0t1

2007-11-24 11:47:29

Wow. Wow. Wow.

You got me to say wow.

Its so nice, If I had a cookie I would give it too you. (*munch*)

Sebo

2007-11-24 12:27:43

Lol :) Thanks mr. Roboto :P

S.R.L.R.S

2007-11-24 13:18:51


Good script tut with good use of fails…you may have wanted to put a else statement in just to round out the if…then…else progression, and then the "no need" statement for the else. A good habbit for beginners to get into.

Sebo

2007-11-24 13:23:08

Yeah, I'm thinking of more things to put in, Because way back when(probably is changing now) I saw people applying with scripts like



program Autominer;

begin
repeat
FindColor(x, y, noob, noob, noob, noob, noob);
ClickMouse(x, y, True);
wait(300); //WTH?!?!
until false //OMG.
end;

Cerium

2007-11-24 21:58:42

Nice tut:)

Now i see why i always get that damn annyoing "unexpected ending"

End. and End; :)

pshynosis

2007-11-25 08:18:48

really helpful!

mastaraymond

2007-11-25 08:30:00

Very nice! But, you should use some more standards..

Sebo

2007-11-25 10:09:10

Yeah, So people get into the habit of doing it in the beggining.

I know what you mean :)

WhoCares357

2007-11-25 19:43:59

All you need to do is tidy up your syntax standards. Use a pattern while writing scripts. Other than that, good tutorial.

-Spartan-

2007-11-26 19:51:40

Thanks for the tut i learned a lot. Explained very well.This tutorial will help lots of people including me. This explanation has made me 1 step closer to becoming an expert script writer.

Sebo

2007-11-28 21:59:49

Your all very welcome, My next tutorial will be…. lol I don't know. Anyone got suggestions? :D

osmm

2007-12-27 01:25:46

Yea, its cool. I learned MC and MI :D. Otherwise you could work on the depth of your tut's. A lot of people need deep explantions.

Also don't double post. You made a tut to teach people. Now you teach the double posting, even as an srl member =/.

P1nky

2007-12-29 01:01:06

LOOKS GOOD! good for those beginners i reccommend this tut =D

Sebo

2007-12-29 02:35:42

Thanks for the good comment p1nky, but people keep pressing the no, but doesn't explain why.. so i'm ignoring those.

kevin0095

2007-12-29 17:10:14

thanks sebo!

Sebo

2007-12-29 17:12:51

No problem :), enjoy your stay at SRL btw :)

mynigga

2007-12-30 03:50:54

Sweet, this tutorial helped me get moving along my way with some basic knowledge, thank you.

Hurgymcgurgygurg

2007-12-30 23:22:54

Thank you very much, I've been reading a lot of these other,

ULTIMATE GUIDES FOR NOOBS!

and they really were good reads but did not help with the transition to actual applying and making scripts. This is really helping me make my first script, since I'm trying to transition this into an AutoMiner and trying to add a Progy Report, and some simple Anti-Ban, Randomness, and Anti-Random.

I've gotten stuck though, for some reason I get this,

Line 35: [Error] (15707:1): Unknown identifier 'DropTo' in script C:\Program Files\SCAR 3.13\Scripts\PowerMiner.scar

It is not recognizing your DropTo command on my Computer, I know its a real nooby question, with probably a real easy solution. But can you help?

The only thing I can possibly think of is, my SLR Library on SCAR is not loaded right or out of date, is this it?

Again I have about 2 days experience so sorry if this ticks you off or something…

Sebo

2007-12-30 23:54:25

Can you post the script, I will explain what you did wrong. :)

Hurgymcgurgygurg

2007-12-31 01:19:39

Sorry I don't know how to do the fancy inserted script list, but here it is ugly way.

program HurgysPowerMiner;
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/Mining.scar}

var
x,y, TLoads: Integer;

const
RockColor1 = 4813212;//Select Color From Rock Your Using
Loads = 2;//Loads you want to do
WaitTime = 5000;//WaitTimeBetweenRocks (3000-10000 MS)

Procedure SearchRock;
begin
if not LoggedIn then Exit;
repeat
if (FindColorTolerance(x, y, RockColor1, MSX1, MSY1, MSX2, MSY2, 10)) then
Mouse(x, y, 3, 3, True);
Wait(WaitTime+random(1000));
until InvFull;
if InvFull Then
TLoads := TLoads + 1;
DropTo(2,28)
end;


begin
SetupSRL;
SearchRock
end.

yurmomsmom9

2007-12-31 13:29:52

very helpful thank you so much :) :D

Sebo

2007-12-31 17:33:30

@ hurgym your problem is that I think they change/renamed Dropto to something else, and since I really never needed it, I just did DropAll;

Kosaki

2008-01-01 09:57:31

thanks for the tutorial :)

I am a c#/c++ coder and this tutorial helped me to learn the differences between the languages.

Sebo

2008-01-01 20:16:16

No problem, but SCAR scripting is pretty easy right?

Man, if there were tutorials like this in the old days, I would be much better at scripting.. LOl.

0744803

2008-01-01 22:36:19

One of the most helpful tuts I have found. Helped me learn more about the includes provided. I didn't know about the MSX1 MSY1 and stuff so thanks for adding that on!

Sebo

2008-01-01 23:02:37

No problem, and thanks for posting, hope you enjoy scripting, once you get into more advanced stuff, it is sooo much fun and addicting.

MasterSparta

2008-01-02 00:32:04

Nice guide. It has helped alot in making that "first step."

Sebo

2008-01-03 00:30:47

thanks, appreciate the good comments, and to answer your signature, it's spongebob sqaurepants. :)

Moresbetter

2008-01-04 12:18:19

very good tutorial, made things alot more clear to me

Sebo

2008-01-05 18:56:43

Thanks for reading, I might begin to make a new one, soon.

Mikool

2008-01-07 23:02:09

Thank you SOO MUCH!! you made me learn so much in such short paragrapths the only trouble i have is the commands i don't know all of them >_>

Sebo

2008-01-11 20:45:34

Yes, there are so many commands, I could not list them all, I would if I could :)