PDA

View Full Version : Everything (Or Most Of What) Beginners Need To Know



Pure1993
01-31-2008, 03:05 PM
Everything Beginners Need To Know


By: Stur Pure


I released this a bit sooner than I planned, my intermedian guide is not yet finished, but I got a little bit impatient. :D
Enjoy reading this :)


1) --How to Setup a Script (total basics)—

A script must contain three basic things:
-It must contain a Name
-It must have a Start
-It must have an End
That’s pretty Logical

Now, it would look like this:

Program New;
begin
end.


“New” is the current name, you can choose whatever name you want to, except that it can't include spaces, dots, or most of the other symbols. Well, that’s pretty much it, so far.

2) --Variables and Constants—

A script won’t run without you having any variables or constants in it. Well, actually, you might be able to make one, but it will be 100% repetitive, and have no fail-safes what-so-ever, so you need to understand these.

2.1) Variables

There is a good and a bad news about these:
-The bad news is that you will need to understand them in order to script!
-The good news is that they are unbelievable easy!

I bet you learned that variables are letters which can represent any kind of number, right? Well, let me tell you something: SCAR is no exception! You Use variables, when something doesn’t remain constant, meaning it can change. For example, a ball which is being thrown won’t always be in the same position, nor will it fly in a straight line or already determined speed. So, we need to look where the ball is located right when we need to know it, because we won’t know hours ahead where the ball will be when we need to do something with it.

To make this clearer, I will use an almost scar example: You want your program to click on a little circle which is moving at random. Now, we don’t know where it will be when we start the program, because we need to click the circle a long time after we actually started the script. That is where variables come in. We can “look” at the ball, and record the data of where we found in onto our variables, for example x and y (x and y should always be used, because they are the things which are being used on coordinate planes in real life, can a screen is nothing other than a coordinate plane). Pretty simple, right?

2.2) Constants

Now, what does the name imply? Well, to all of you who speak somewhat English (now don’t say English is your second language and that’s why you don’t understand it… because I am German, and English is my second language), a constant will constantly be the same.

For example: If you see a huge 10 ton rock in the forest, you can be pretty sure it will still be there when you come back the next day.

In Scar, it is no different: If you want to make a program to click the Start button, and you then create it, and don’t change anything in the options, that start menu will still have the same coordinates as before, thus you don’t need to “look” for it, because you know by the time you start the script where it is.

2.3) Adding Variables Constants

Okay, so now you know what they are, but this really has you wondering: How the heck do I use things as variables and constants in my script, well, just take a look at my next “program”:

Program New;
const
StartSymbol = 5155911;
var
x, y: Integer;
begin
end.


(Just to take some weight away, we will get to colors later, no need to open six or seven other tutorials, this one will explain itself, just hang on for a bit =) ) Now, there is something new in there, something called an integer! Now, don’t let that scare you off, it is a very easy to tackle, harmless little thing. An integer is simply a number. Because, a variable could in theory be anything, it could be a fruit color, a number, and lots other things, and by saying it is an integer, we know it represents a number.
The Constant is simple, the color of the start button was green (that is the color which 5155911 stands for) when you created the script, and it will stay green if you don’t change any settings.

3.1) (Learning Basic Functions) Understanding Colors

Colors are very easy to understand, and you will use them throughout your “scripting career”, be it from simple color finding functions to more advanced find object functions. First of, what is a color?
Well, in SCAR, a color is a number. The entire vast amount of colors is numbered. Now, you might ask how to determine the number of a color. You can’t normally do this manually because the numbers aren’t just numbers following a simple code where 0 is white and 999999 is black. A number might just be 10 higher or lower than another number, but be a completely different one, or one color might have the number 53481 and the color which is just a tiny bit lighter might have the number 94580. What I am trying to tell you is that the colors aren’t ordered, but luckily, there is a little tool which does it for us, it is named color picker, and it represented as a little icon at the coordinates of (270, 60) ;)
Just click on it, and your screen will freeze, except for the mouse. Now just move your mouse on the color you want to know the number of, and click, a message like this will appear in your debug box:

Color Picked: 15446384 at (300, 7)


This means that the color name is 15446384, and is located at (300|7) on your screen (x obviously being 300 and 7 obviously being 7). As you see, you can use this tool in order to find certain locations.

HINT: The debug box is the box in the bottom of the SCAR window. This is where all the important information is going to be visible, for example errors or progress reports (this will only appear of course if you created one, I will get to those later).

3.2) (Learning Basic Functions) Moving the Mouse

So, now you have read over 1000 words on what a basic script is made out of, what variable and constants are, how to apply them, and what colors are. In order to clean up the basics, we only need to learn hot to move the mouse and hot to apply color finding to our scripts.

Now, some of you will stop right after reading how to move a mouse, and attempt a completely useless script, which won’t work anyways, so if you stop after this one, you can forget about scripting, because you won’t make it far, believe me. There isn’t a single good script out there that is using only mouse moving functions.

So, Now that we cleared that issue out of the way, it is time to get to it. There are many mouse moving functions, but I only suggest 2:


MouseSpeed := Speed: Integer;
Explanation: This doesn’t move the mouse, but it declares how fast the Mouse and MMouse are supposed to move torwards x and y. 12 is usually a good thing to put in there. In sscript it could look like this:
“MouseSpeed := 12;”

Mouse(var rx, ry: integer; sx, sy: Integer; Click: Boolean);
Explanation: This one moves the mouse a bit human-like, which makes it hard to detect for Runescape or whatever other software you are using. rx and ry are the normal x and y values, while sx and sy determine by how many pixel the click can be off from the real x and y values. For Click put in true or false, true left click, false right click. In a script it could look like this:
“Mouse(125,50,2,2,true)”
This would move the mouse to (125|50), and then left click with the accuracy of two pixels, so it might hit anywhere from (125|50) to (127|52).

MMouse(var rx, ry: Integer; sx, sy: Integer);
Same as Mouse, except it doesn’t click with the mouse. Could look like this in a script:
“MMouse(125,50,2,2)”


This is quite easy, there shouldn’t be any questions on this, but if there are, just send me a private message.

3.3) (Learning Basic Functions) Finding Colors

Now, I put in mouse moving between the two coloring articles, because what is a color finding supposed to do, if you can’t move the mouse and click on it? Sure, you could just record the coordinates with a special function, but where’s the fun/reason in that?

Now, what do we remember? We know that all colors are integers, meaning that they are numbers, we know that colors are often constant, meaning that they don’t change, and we know that x and y are variables used to record a location on the screen. So, let’s put your knowledge to the test, Here is a color finding function:



FindColor(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;
Explanation: this one will look for a given color within the parameters of xs, ys, xe and ve. Then it will save the exact location onto the x and y value. In a script it might look like this:
“FindColor(x,y,532685,0,0,125,50)”
This will look for the color 532685 within a “box” given by the locations (0|0) and (125|50) (this would be from the top left corner of your screen). After it found the colors, it will record their position to x and y, but only IF it found the colors.



Okay, so what do we use color finding stuff for? Well, it is an essential part in creating a script. In Runescape for example, it could find a tree for you, or maybe a rock (even though there are far more advanced things to do that, this will be good enough for the basics). Now, let’s combine it with mouse moving.

3.4) Applying The Basics

Okay, so you have all that theory behind you, and you worked hard to understand most of it, and now it is time for the little golden nugget: going from the theory into practice! Now, you shouldn’t stop after reading this either, because there is tons more to learn, but for now, this is a little marker of the first step on a journey of a hundred miles. =)

I think it is best I just put up a little script, and explain later on, will be much easier that way…


Program ExampleOne;
{.include srl/srl.scar}
var
x, y: Integer;
const
MyBlueColor = 12742455;
begin
MouseSpeed := 12;
wait(2000);
If FindColor(x,y,MyBlueColor,0,0,125,50) then
begin
Mouse(x,y,2,2,false);
end;
end.


Okay, let’s start from the top. First of all we named our program ExmapleOne. Right below it we typed “{.include SRL/SRL.scar}”, this tells the program to actually include all the SRL functions, because you have to remember: SCAR is only the Program, Pascal is the basic platform, and SRL is a collection of commands created for autoing.

Next we declared x and y to be variable integers, meaning they can be any number. Then we declared the constant, we said that MyBlueColor is 12742455, so whenever we need to use that number, we can just write the name, and the program will know that it is the color.

Then we had the main begin, which obviously told the program to start. In order for the mouse movements to be at a decent speed, I included the MouseSpeed function, otherwise it would take a couple of minutes for the mouse to get from point a to point b. then we told the program to wait 2000 milliseconds which are equal to 2 normal seconds. This has no real Use or Purpose, except that it allows us to catch our breath.

Now, it gets a tiny bit more advanced. Do you remember that I said something like: “Findcolor will save the location of the color, IF it finds it…” Well, that’s exactly that. You see, if we put in an “if” and then a “then”, and then a new “begin” in the next line, all the stuff which is between that “begin” and the “end;” which is in the right place, will be skipped if the color was not found. If it was found, it will run through everything that comes between the “begin” and “end;” I put this in there because if the color is not found, what values will have x and y? Exactly, the values from the earlier defnition, and what would that do, except make the script to mess up?

Well, if the color is found, it will move the mouse to where it was found, and right click on it, with an accuracy of 2 pixels. After that, we have two ends, that is because for every begin there has to be an end, otherwise it will be an identifier expected error. A little thing you should know is that if there is a semi-colon after an end, it means the script will not be finished. If there is a dot after it, it means it is final, nothing after it will work.

Now, that was a lot of text for a simple script, I hope I made it somewhat clear how it works.

Congratz!!!!! You now know everything you need to know for beginners! I still suggest you read up on some of the other guides, in case I missed something, and to get a broader understanding of SRL. My next tut will be for intermedians, covering map walking, auto coloring, DTMs, and some other enat functions. be sure to check it out!
Hope to see you soon (please comment and rate, I would appreciate it A LOT ).

EDIT: If this script didn't help you, I would appreciate it if you would leave a comment, and not just vote that it didn't help you and leave, because the reason why I made this poll is to get people to say what I should improve, but being silent won't help anyone.


Well, not everything I planned to have in here actually is in here, like making progress reports, finding bitmaps, and some other things, but I barely have 30 minutes of free time each day at the momment. Will edit it over time.

EvilChicken!
01-31-2008, 03:12 PM
Good job, BUT:

Use SCAR tags, not CODE tags.
Choose a normal, easy-to-read-color for the text.
I didn't bother to read it all.

EDIt: Your poll is a checkbox also..?

Rikje
01-31-2008, 03:17 PM
in 2.3:
Program New;
constt /// <<------------------
StartSymbol = 5155911;
var
x, y: Integer;
begin
end.


Nice tut :)

Pure1993
01-31-2008, 03:19 PM
It still has some errors in it, because I did this in Word, and copy pasted it, will fix the errors that occur over time.
Thanks for your comments, fixed most of it already. :)
EDIT:

EDIt: Your poll is a checkbox also..?
What do you mean?

MylesMadness
01-31-2008, 08:16 PM
He means you can pick more then one answer in the poll.

Pure1993
01-31-2008, 08:27 PM
Yeah, because someone could think this is a good tut, but still think it is a bit confusing, so he would mark both of them, pretty simple, ey? ;)

Jackrawl
01-31-2008, 09:14 PM
You're wrong, the program name cannot be anything. It can't contain spaces, and must be all one word.
You're also wrong about the FindColor bit. If it does not find the coordinates of the color, then nothing really happens. It'll go to the previous coordinates, or it will go to 0,0, depending on whether or not there were previous coordinates.
You also said 'Wait' has no purpose. It does.
program New;
var
x: integer;
begin
repeat
x:=x+1;
writeln(inttostr(x));
wait(1000);
until false;
writeln('This has no purpose or lesson whatsoever.');
end.I have yet to see a script with no form of wait, as it is used in 'FFlag,' repeats, antibans, randoms, banking, and just about everywhere.

footballjds
01-31-2008, 10:46 PM
don't know if you noticed this but: begin
end. compiles fine, no need of name :duh:

osmm
01-31-2008, 10:54 PM
JackL your wrong: My script is named "program Owessm_Willow_Banker" that is not one word ;). Basicly _ replaces " ".

Pure1993
02-01-2008, 01:16 PM
hmpf, guess you guys are right, will edit this right away. Thanks for the comments though :p
EDIT: Okay, I changed everything which needs to be changed. :)

dillbagz
02-03-2008, 12:46 AM
some inconsiderate person messed with your poll by ticking everything.

just want to say gratz on your tut i can't wait to we try and make a script.

NiCbaZ
02-03-2008, 07:10 AM
nice tut well done very nice layout but why you post the text in blue?

Pure1993
02-03-2008, 12:46 PM
Thanks for the feedback :)
To answer your question: I put the text in blue because it is my favorite color. :D Of course if anyone has difficulty reading it, i will consider changing it, but I personally like the style. :D

Hugolord
02-03-2008, 12:51 PM
A* man, I'm beginning to like you, it's people like this we need at SRL.
GJ

Pure1993
02-03-2008, 01:03 PM
*smiling* Thank you Hugolord (you have no clue how good that makes me feel when I hear comments like that :D) :)

cj_404
02-03-2008, 11:33 PM
Thank you, this helped me a lot.

Lee Lok Hin
02-04-2008, 12:42 AM
MMouse! That's it.

Forgot about that procedure, :p

Thanks

dillbagz
02-04-2008, 08:33 AM
Thanks for the feedback :)
To answer your question: I put the text in blue because it is my favorite color. :D Of course if anyone has difficulty reading it, i will consider changing it, but I personally like the style. :D

i can read it perfectly well and looks very pretty. :)

Pure1993
02-04-2008, 01:16 PM
Haha, cool, glad you uys liked it! :D
BTW: Please feel free to add to my rep and to rate this thread. :D

Not a L33cher
02-04-2008, 10:44 PM
Wow thanks really helpfull I'll refer to this when I need help.

Pure1993
02-04-2008, 10:49 PM
Cool, glad it helped :)

dillbagz
02-06-2008, 02:59 AM
when are you making your first script?

Pure1993
02-10-2008, 05:03 PM
Well, I'm already quite far with one which I will use for members, so I have to work on that myself, but If you want, we can start on our team script together any time.

Xterminator
02-11-2008, 06:50 AM
wow thx for this tut, really helped
but i still got some problems with making scripts:(
but when i succesfully made 1 ill post it

dillbagz
02-11-2008, 07:23 AM
well stur so your using the script to apply for members? can i look at the script i wont post it i just want to see your lovely work.

Pure1993
02-11-2008, 02:04 PM
It's not done yet, you can look in the stories and blogs section of this forum, there I have a little blog on how far I am.Will send it your ways once I am done (btw, I am already applying for members with a different script, the one I am creating now is a back-up in case I get denied :D)

dillbagz
02-12-2008, 05:49 AM
gratz on srl member once i know how to script i can apply

Pure1993
02-12-2008, 10:56 AM
Thanks, good luck learning srl. :)

i grab loot
02-14-2008, 11:43 PM
wow a very good TUT good job 10+ :D

imlvl127
02-15-2008, 01:00 AM
Thanks a lot for taking the time to make this Tut to help people like me :) Now I know a little more. All the other tutorials seemed a little to advanced but this one had the basics. Now i can move on to more advanced ones.

Thanks

Pure1993
02-15-2008, 09:13 PM
Thanks for teh comments, I'm glad it helped :D
Good luck with the more advanced tuts, imlvl127 :)

God of Draynor
02-19-2008, 01:38 AM
Dude, seriously awesome guide cleared up a lot of questions i had thx soo much. :D

Pure1993
02-20-2008, 01:29 PM
Sure, no problem, and thanks for the comment. :D
If you need any more help, feel free to ask me, I will try to answer your questions to the best of my abilities. :)

xxx_Drew
11-06-2008, 04:13 AM
Good tutorial, it taught me about some SRL functions instead of the basic SCAR ones.

Thank you.

RuneItBack2Front
11-24-2008, 07:36 PM
Thanks for the great tutorial. I am just getting starting writing my first script and you helped out a lot!