Page 1 of 20 12311 ... LastLast
Results 1 to 25 of 483

Thread: Unmatched Beginner's Guide to Scripting Scar

  1. #1
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Unmatched Beginner's Guide to Scripting Scar

    Please, Enjoy this. And please post feedback as well as ways of improving this tutorial. I made it for you and I want it to be the best it can be.

    I have released my next tut. It is called "Hands On" because it is hands on (duh). Hope you like it:
    Unmatched Beginner's Guide to Scripting Scar (Hands On)

    Merry Christmas.
    Happy New Years.
    And Happy/Merry Any Other Holiday Which is Approaching.


    !WARNING!
    THE COMMANDS USED IN THIS TUTORIAL ARE OUTDATED.
    Do not use any of the Mouse (moving or clicking) commands on Runescape. Do not use the SendKeys command on Runescape either.

    The include SRL (made by the generous people on this forum) has created greatly improved commands that are undetectable by Runescape. THE INTERACTIVE COMMANDS USED IN THIS TUTORIAL (mouse movement, mouse clicking, typing) ARE NOW DETECTABLE. DO NOT USE THEM ON RUNESCAPE OR YOU WILL GET BANNED. I made a short tutorial on some of the more common SRL commands. You can find that tutorial Here.

    Unmatched Beginner's Guide to Scripting SCAR
    by WhoCares357


    <><><><><><><><><><><><><><>
    ---Created by WhoCares357---
    --Edited by SomeGuy357--
    --Special Thanks to Kaitnieks for creating Scar and Freddy1990 for continuing it--
    <><><><><><><><><><><><><><>

    Table of Contents

    I. Introduction
    II. Requirements
    --A. Equipment
    --B. Personality
    III. Scar 2.03
    --A. Info
    --B. How to Use
    IV. Format
    --A. Layout
    --B. Procedures
    --C. Colors
    --D. Comments
    V. Variables and Constants
    VI. The Middle
    --A. Functions/Commands
    ----1. Wait
    ----2. Keys
    ----3. Color
    ----4. Mouse
    ----5. Bitmap
    ----6. Others
    --B. Random
    --C. Loops/Until
    VII. Finalization
    --A. Includes
    --B. Good Luck





    +--------------------- [Introduction] ---------------------+

    I have read many tutorials about Scar and even other language tutorials that all lack the essential details for true beginners. I have designed this lengthy, but efficient tutorial for the language of PASCAL’s little pal, Scar. Scar is a simple program for macroeing in a game called RuneScape. You can find the game here- http://www.runescape.com.

    You don’t have to use Scar for RuneScape, but that is what it was intended for. This is just a small jumping stone to your career or interest in programming and creating software. I hope you enjoy your time in this tutorial and wish you the best of luck in your future.

    By the way, if you have Scar 2.03 or later version and know how to use it, just skip the Requirements and Scar 2.03 to avoid a few extra minutes of reading.


    +--------------------- [Introduction] ---------------------+




    +--------------------- [Requirements] ---------------------+

    --Equipment--


    Hmm, let's see.

    First of all you will need a functioning pc. Of course if you didn't have that, how could you be reading this?

    Second thing you need is Scar version 2.03 or later. If you do not have this, download it from this URL- http://www.dylock.net/scar/.
    If the location of Scar download is changed then refer to http://www.sythe.org for the new location. If that is no longer available then just search http://www.google.com.

    Finally, you will need drive and must want to learn this easy language of Scar. I can not make you learn it, so you must stick with it even when it proves a little difficult.



    --Personality--


    One word: NEATNESS.

    First thing with this is of course grammar. Especially in your comments, make sure to not abbreviate words. Also there are certain things you should capitalize and others you should leave in lower case. You will get the feeling of neatness while you look through my example codes.

    Why? Well, neatness builds reputation and will help if you venture into a deeper programming language like Java, C++, or others by mending your habits right off.

    +--------------------- [Requirements] ---------------------+




    +--------------------- [Scar 2.03] ---------------------+



    --Info--


    Ever heard of RuneScape? Yup, that is exactly what the program Scar was made for. Scar is a compiler. A compiler is a program that transforms what you tell (code) the program to do into computer language. The computer then does what it is told to do from this code. However, what makes Scar special for RuneScape players is that the creator Kaitnieks built in some functions or commands especially for RuneScape. Scar is now widely used for macroeing (cheating) on RuneScape.



    --How to Use--


    Once you download and install Scar 2.03 or later version you will be forced with the question of how to use it. It is actually very simple.

    Open your Scar 2.03 or later version and read the following.

    First thing you will have to do is download the Includes. Press File-Download Includes and make sure all of the boxes are checked. Then press download, or overwrite. It will take a few moments to download.

    Second, a few shortcuts should be learned to avoid complications once you use your scripts. For these shortcuts, you do not need to be in Scar. "Ctrl+Alt+R" Starts the script. "Ctrl+Alt+A" pauses the script. "Ctrl+Alt+S" stops the script. "Ctrl+Alt+P" solor picker. (Copies color number into Debug Box, I'll go over colors later)

    The color picker is one of the most important tools in Scar. I will explain what it does in Format-Colors. I will explain how to use it here. Click on the “Color Picker” in the Scar toolbar or just press “Ctrl+Alt+P” and click on the color you want. In the lower part of Scar (Debug Box) you will see something like this.

    Code:
    Color Picked: 16777215 at (182, 364)
    The first big number, “16777215” is the color number.
    “(182, 364)” are the coordinates or location on the screen where the color was found.

    Third thing that Scar requires for RuneScape is to set the Client Window. I will now explain the purpose of this. Get ready for some simple math. If you know about computer coordinates system, skip this part.

    Let's take a look at your compute screen. If you did not know, your computer is made up of pixels. Pixels are like squares of color that combined, create your screen image. Each pixel is a different coordinate. Pixels also use colors. If you have studied math, you will know that coordinates use x and y.
    "X" is the distance from the origin (0) horizontally (left to right) left of 0 is negative, right is positive
    'Y" is the distance from the origin (0) vertically (up to down) up of 0 is positive, down is negative
    This is how it would look like.

    P.S. The "Y" for computer screen coordinates is reversed.(Y becomes –Y and the other way around)



    _________-Y__________
    ------------|------------
    ------------|------------
    ------------| ------------
    -X----------0,0---------X
    ------------|------------
    ------------| ------------
    ------------|--5, 25----
    _________Y__________


    An example of a coordinate would be this.
    Code:
    (5, 25)
    As you can see, this coordinate is 5 to the right of 0, and 25 down from 0.
    In a coordinate x always goes before y.

    Now how this applies to Scar.

    Now, Back to your computer screen: Most computer screens now-a-days have a resolution of at least 1024x768(Highest coordinate of 1024, 768), but everyone's is different.

    Now, what setting the Client Window prevents, is miss-calculating the coordinate you do something in. Instead of letting the computer coordinates be used, this tool makes the RuneScape screen become the whole computer screen for Scar. Like this.

    Before Setting Client Window

    Code:
     0, 0------------------------------|
    |----100,100--------------------|
    |---| Rune---------|------------|
    |---|----Scape-----|------------|
    |---| ---------800,800----------|
    ----------------------------1024, 768
    (How Scar Sees It)

    After Setting Client Window
    Code:
    0, 0---------------|
    |----Rune--------|
    |-------Scape----|
    |------------------|
    |--------------700, 700
    (How Scar Sees It)

    As you see by setting the Client Window, Scar turns RuneScape window into the whole screen for itself.

    The steps to setting the Client Window are the following.

    1. Click and hold the circle around an x looking button at the end of the toolbar.
    2. Drag it onto the RuneScape screen and release.
    3. If you see a white box shape close in on the RuneScape screen then you did it correctly.
    4. It is usually good to do it twice, just in case.

    One last thing: the Debug Box. The Debug Box is the bottom text box on Scar. This text box is used for storing the color numbers, and all other information. It also displays the errors.

    That’s all for explaining Scar my pupils. Now let’s begin the fun part: scripting.



    +--------------------- [Scar 2.03] ---------------------+




    +--------------------- [Format] ---------------------+


    By now, you should have your Scar 2.03 or later version open. You should test some of the examples or/and even try to make your own to understand this better.



    --Layout--


    As you may have seen on multitudes of other Tutorials, the layout of Scar and even Pascal language is the following.
    SCAR Code:
    program NewExample;

    begin

    end.

    As you can see, every script begins with program name (NewExample;). You should be able to guess, that this is for naming your script. This is not necessary but is accustomed to tell the users what the script is for. You will have to leave a space after “program” before writing the name of the program. To practice good habits, always write your program names as I have here. Have the first letter of each word in the name (not the “program”) capitalized.

    For example do this
    SCAR Code:
    program NewExample;

    and not this.
    SCAR Code:
    program Newexample;

    Notice how in the first example every first letter of a new word in the name is capitalized.

    In the program name, there can not be any spaces.

    For example this would be wrong,
    SCAR Code:
    program New Example;

    and this would be correct.
    SCAR Code:
    program NewExample;

    Also in Scar every line ends with a ;. This excludes “begin”, the last “end”, and a few other bold words (Certain codes will turn bold when written in Scar) that we will go over later. This is not necessary but it will be necessary if you ever join another language of programming. Good habits to grow into will help.

    I will post the first example again so you do not have to scroll.
    SCAR Code:
    program NewExample;

    begin

    end.

    Ok, now to the next part. As you can guess, begin is the beginning of your instructions, while the end is the end of them. Begin, like program and end are going to be bold. Just for the sake of neatness try to never capitalize the words that become bold when you type them into Scar. Now you can see that after “end” there is a dot. This dot only applies to the last end.

    In your procedure, you will most likely have more than one begin and end. Now, when you have more than one beginning and end, your end, on every other end than the last one, will change to this: end;.

    Here is an example.
    SCAR Code:
    program NewExample;

    begin

     begin

     end;

    end.

    Remember that ; is not placed after begin, the last end., and a few other codes that we will go over later.


    In the following example you will see three separate begin and ends.
    SCAR Code:
    begin
     begin
      begin
     
      end;
     end;
    end.

    As you can see, I have aligned the “begin” and “end” with one extra space for every new begin and end. This format is not necessary, but once again neatness and consistency will help both you to edit your work easier, and the user to see what you have done.

    We will learn what goes in the middle of this later.




    --Procedures--


    Now that you know a little of the layout in Scar scripts let’s learn something new: Procedures

    A procedure is just a piece of the script that does something. This is difficult to explain, so I will be using some examples here.

    First let’s look at the layout of a procedure.
    SCAR Code:
    program NewExample;

    procedure Stay;
    begin
      Wait(500);
    end;

    begin
     Stay;
    end.

    This is the layout. As you can see the name of the procedure is in the same format as in the program name. One thing you will notice once again, is that all lines, except for begin and the last end, end with ;. Like I said, good habits will eliminate the small errors in your future scripts.

    As you can see, a procedure has its own begin and end. It can have more than one begin and end as it becomes more complex.

    Now from this example you get your first glimpse of a command! “Wait(500)” is a command that tells Scar to wait 500 milliseconds. (1000 Milliseconds=1 Second) We will go through this more thoroughly later.

    I will copy the example here again so you don’t have to scroll too much.
    SCAR Code:
    program Procedures;

    procedure Stay;
    begin
      Wait(500);
    end;

    begin
     Stay;
    end.

    Alright, now as you can see, after the procedure I have a second set of begin end. This is where it actually does things. You see, procedures aren’t used unless you tell the program to use it. It is like a part of the script written so that later you don’t have to write out the whole thing again. As in this example, the procedure “Stay” will now replace the need for you to write out “Wait(500)” every time you need it.

    Let’s look at an example with two procedures, now.

    This is an example:
    SCAR Code:
    program Procedures2;

    procedure Write;
    begin
      Writeln('Hi, you are doing very well with this learning!');
    end;

    procedure Stay;
    begin
     Write;
      Wait(500);
    end;

    begin
     Stay;
    end.
    Don’t get scared!! I will explain this step by step.

    As you can see, I have just added on to the last example. I have added the procedure “Write”. This is another command. “Writeln('')” is a command that writes what you put between '' in the Debug Box. By the way, the “l” in “Writeln” is “L”. I got this confused with “I” the first time I learned the command.

    Once again, I wrote the procedure “Write” so that I would not have to go keep writing out Writeln('Hi, you are doing very well with this learning!') every time.

    Now, you might see that I included the procedure “Write” in the procedure “Stay”. You may include procedures in other procedures when you write your own scripts. However, there is a rule to this.

    Scar will not allow you to include a procedure if the procedure you want to include is below that location.

    This may sound confusing, but think of it like this. In my first example of two procedures, I wrote out procedure “Write” and placed it before procedure “Stay” so that I could use it in there. If I had written the procedure “Stay” with the procedure “Write” included, and then typed the instructions for procedure “Write”, it would show up as an error.

    If you are still confused here are examples of a correct and wrong way of including procedures.

    Correct way.
    SCAR Code:
    program Procedures2;

    procedure Write;
    begin
      Writeln('Hi, you are doing very well with this learning!');
    end;

    procedure Stay;
    begin
     Write;
      Wait(500);
    end;

    begin
      Stay;
    end.

    Wrong way.
    SCAR Code:
    program ProceduresBad2;

    procedure Stay;
    begin
     Write;
      Wait(500);
    end;

    procedure Write;
    begin
      Writeln('Hi, you are doing very well with this learning!');
    end;

    begin
     Stay;
    end.

    Including procedures will be very helpful when your scripts become more and more complex. Just remember the rule.

    If you still do not understand it, try to look at the examples and notice the differences.




    --Colors--


    From the title you may be saying, “Has this guy gone bunkers, what does this have anything to do with colors?” Well, no I’m not crazy, and Scar has everything to do with colors. Scar in itself even has a color picker! (“Ctrl+Alt+P”) If you have read my long explanation of coordinates, (Congratulations on finishing it by the way) you will notice that I included the fact that pixels store colors. Now every color has a number. Yup, that’s right. What the Color Picker does is it finds the colors number. Another surprise! Colors have numbers. (When you pick a color with scar the number will appear in the Debug Box) This number can then be used in functions/commands to search for the color and do something with it. (We will explore these functions/commands later)




    --Comments--


    Sometimes, while you write a script you will want to make a note or two or maybe a few dozen. Comments are used for this very reason. Along with this you can also give users information on the constants that they fill in. (We will explore this in the next chapter)

    There are two ways to write a comment.

    The first way is by putting // in front of the comment.
    Here is an example.
    SCAR Code:
    program ExampleComment1; //This is the program name

    begin

    end.

    The second way is by using {}. During this sort of comment you must not forget to set }. If you forget that, your whole script from { will become a comment.
    Here is an example.
    SCAR Code:
    program ExampleComment2; {This is the program name}

    begin

    end.

    Try copying these two examples to Scar. As you will see, comments turn green.


    +--------------------- [Format] ---------------------+




    +--------------------- [Variables and Constants] ---------------------+



    --Variables and Constants--


    Variables and Constants may be hard to understand until you use them.

    First of all, both variables and constants come after the program name and before anything else.

    This is an example:
    SCAR Code:
    program VarAndConst;

    var

    const

    begin

    end.

    Let’s look up close at variables first. Just like constants, variables store information. However, variables differ from constants because variables can be changed throughout the whole script. (Hence the name variables [varied]) I will come back to this a little later.

    There are four basic types of variables: Integer, String, Boolean, Extended.
    I won't cover others, because they are of no use to you until you are more advanced.

    Integer-Stores a positive or negative whole number
    Extended-Stores any numbers (Including decimals)
    String-Stores any characters (Mostly used for Writeln or SendKeys)
    Boolean-Stores the values “True” and “False”

    First, let’s learn how to include them. To include a variable you must first write var. Afterwards you can either skip a line or just start on the line below this. Now first you have to decide which variables you will need. This could be one letter or a word, but try to make it something that makes sense. Don’t put anything random. If this is hard to understand just follow my example.

    This is an example:
    SCAR Code:
    program VariablesExample1;

    var
    i: Integer;
    Greeting: String;
    Yes: Boolean;

    //Rest of the script

    As you can see, I included an integer, a string, and a boolean.

    Let’s look at these one by one.

    First there is the integer. Now, if you aren’t too shabby at math, you will remember that integers are whole numbers. They can never have a decimal or fraction. They can also be either positive or negative. In scripting, integers are just this.

    The most common integers are x and y. What these two integers most likely store are coordinates. X is for the x coordinates (First part of coordinate) and Y is for the y coordinates. (Second part of coordinate) Of course you can use other letters for this, but x and y is the most common way to go.

    To use integers, you must first declare them. What this means is you have to tell the program what the integer is. For example if I had the integer “i”, I would have to tell the program what i stands for.

    Here is an example:
    SCAR Code:
    program VariablesExample2;

    var
    i: Integer;

    begin
     i:=0;
    //Rest of the script
    end.

    In this example, I first inserted the integer in the var section. I then declared what the integer equals in the part I wanted to use it.

    Now the great thing about variables, as I have said before, is that they can be changed for different parts of your script. For example, if in one of your procedures, you want the integer “i” to equal 0 and for another procedure you want it to equal 7, you can do that!

    Here is an example:
    SCAR Code:
    program VariablesExample3;

    var
    i: Integer;

    procedure IntegerIsZero;
    begin
     i:=0;
    //Rest of the procedure
    end;

    procedure IntegerIsSeven;
    begin
     i:=7;
    //Rest of the procedure
    end;

    begin
     IntegerIsZero;
      IntegerIsSeven;
    end.

    As you can see, you can use a variable in two different places and have it stand for two different things.

    Now the variable extended is used the exact same way, except that it stores mixed numbers instead of whole ones. (Numbers with decimals or fractions) As a beginner you will most likely not use until a little while longer, so just don’t worry about it for now.

    Alright, now let’s look into strings. Unlike, integers, strings can store any number, letter or symbol. They are mainly used to store characters for functions like Writeln or SendKeys. Once again, since this is a variable we can change it for different parts of the script. Let’s look at an example.

    This is an example.
    SCAR Code:
    program StringExample1;

    var
    Greeting: String;

    procedure Say1;
    begin
     Greeting:='Hello';
      Writeln(Greeting);
    end;

    procedure Say2;
    begin
     Greeting:='Yo!';
      Writeln(Greeting);
    end;

    begin
     Say1;
      Say2;
    end.

    In this example, I used the string “Greeting” in two procedures. I declared Greeting as two different things. Go ahead, try this in Scar and change it up a bit.

    Now-the boolean. This was the hardest variable for me to understand, and I see now that it is pretty difficult to explain. I will try my best.

    As I have defined boolean in the beginning, a boolean just means true or false. Now what confused me when I first started was how to use it. However later I realized that you will almost never use booleans as variables. Once you get more advanced, you will find a use for it, but for now let’s just learn how it works.

    Pascal and Scar work in this format: if, then, else.

    What this format does is ask tells scar: If this is this, then do this, if it is not then do this. Here is an example to explain this a little better.

    This is an example:
    SCAR Code:
    program ExampleIfThenElse;

    var
    i: Integer;

    begin
    i:=0;
     begin
    if(i=0) then
      begin
      Writeln('I is zero');
      end else
      Writeln('I is not zero');
     end;
    end.

    This is how to use if, then, and else.

    I first declared that I is zero. then I began my if, then, else sequence. I told the program: If i is zero, then write i is zero in the debug box. However if i is not zero, then write i is not zero in the debug box.

    Study the layout and try to change a few things up to learn it a little better.

    Now, by now you should be wondering how this applies to boolean. Well, remember that boolean stands for true or false. As I have said before, boolean in variables is mostly used just by Scar. You cannot see the boolean, but it is there.

    Here is how it works. Let’s look at my script again.

    This is an example.
    SCAR Code:
    program ExampleIfThenElse;

    var
    i: Integer;

    begin
    i:=0;
     begin
    if(i=0) then
      begin
      Writeln('I is zero');
      end else
      Writeln('I is not zero');
     end;
    end.

    As you can see, if i is zero then it does something, otherwise it does something else. What boolean does is this. Scar checks if i is zero. “If” i is zero, then Scar returns the value that this is true. “Then” if “If” is true (i really is zero), then it does what you tell it after then. However, if the value of “If” returns as false (I is not zero), you tell it what to do using end else.

    Remember this little fact. You do not have to use if, then, else. However, it makes your script much neater and easier to look at. Also, if you use this layout, you don’t necessarily need “end else”. If you don’t tell it what to do if the value is returned false, it just won’t do anything.

    This might be hard to understand, but just don’t worry about it yet if you don’t understand it. However, you should still learn the layout of if, then, and else. Once you are more advanced, come back here and see if you can understand it.



    Constants!

    These babies are very useful and are very easy compared to variables. You will mainly use these for declaring colors. Just like for variables, use names that make sense. This is especially important for constants because this will mostly be used to create options for the user.

    Alright, let’s explain what constants are used for first. Constants are the exact same as variables except that you cannot change them during the script. This is good for letting the user choose colors for a fighting script or text for an auto talker.

    This is how to set a constant up.

    This is an example.
    SCAR Code:
    program ExampleConstant1;

    const
    GroundColor= 0;//Set the color of the ground here
    TreeColor= 452789;//Set the color of the tree here

    //Rest of the script

    Constants are declared as soon as they are written.

    Now let’s look at a new function for finding colors and use a constant for the color.

    This is an example.
    SCAR Code:
    program ExampleConstant2;

    var
    x,y: Integer;

    const
    FishColor= 19245;//Set the color of the fish

    begin
    if(FindColor(x,y,FishColor,0,0,600,600)) then
     begin
      Writeln('Found Fish');
     end else
      Writeln('Did not find Fish');
    end.

    Let’s look at this step by step. You already know about the program part. Look at the variables I have declared. I have declared x and y as integers. (Whole numbers) You will see how I use them later. Now as you should already know, I have declared the FishColor constant in the beginning of the script. Now I started the script with the format of if, then, else.

    You should already understand this. If you do not, you should look back and study it a bit. Alright, now I will explain the procedure, “FindColor” quickly. First think you will notice, is the x and y. Now, I have declared these integers in the beginning for the reason of using them in this function. The “x,y” are just there to fill in the coordinates where Scar finds the color. The “FishColor” is the constant that we have set earlier. Instead of FishColor you could have just wrote the color number. The last part, “0,0,600,600” tells Scar from where, upper left, to where, lower right, to search for this color.

    In this way, I transferred the color “FishColor” into the function.

    Ok, now once you’ve mastered this, let’s move on. You know how to use constants to transfer colors, now let’s look at how to transfer booleans and strings. These are both very easy, and you should understand them from this example.

    This is an example.
    SCAR Code:
    program ExampleConstants3;

    const
    ShallWeWrite=True;//True to Type, False not to Type
    Write='Hi';

    begin
    if(ShallWeWrite=True) then
     begin
      Writeln(Write);
     end;
    end.

    In this script we have used both a boolean and a string as a constant. We used boolean by asking the user to write True if he/she wants the program to write and then we asked what to write.

    That’s pretty much all for constants. Constants are very fun when you start including options with True and False.

    Have Fun!


    +--------------------- [Variables and Constants] ---------------------+




    +--------------------- [The Middle] ---------------------+


    --Functions/Commands--




    If you have gotten this far, then I will most certainly congratulate you because you just came to the center of Scar. These commands all came out with Scar's first release. They are pretty old (Especially functions like MoveMouse, ClickMouse, and SendKeys) Includes (you will learn in next chapter) are used to produce newer, undetectable functions. You can find the basic ones at http://www.villavu.com/forum/showthread.php?t=6366. For now, just learn these old ones for practice.



    <Wait>


    This is an example:
    SCAR Code:
    Wait(1000);

    This command, though very simple, is essential if you wish to auto in RuneScape or most other games. What this function does is it waits the number of milliseconds you designate it. If this stood by itself, then it would not be very useful. However, there is a randomizer that makes this function more human.

    This is an example:
    SCAR Code:
    Wait(1000+random(200));

    As you see here, I have added “+random(200)”. What this does, is instead of always waiting 1000 milliseconds (Which is very noticeable) It waits a random of 200 extra random milliseconds. With this, the function could wait 1025 milliseconds or 1167 milliseconds.

    We will explore the randomizer option a bit later.

    You must remember that “1000miliseconds = 1second”.



    <Keys>


    This is an example:
    SCAR Code:
    program TypeExample1;

    begin
      Writeln('Hi');
      Wait(1000+random(100));
      SendKeys('Hello');
    end.

    Here are two of the functions to type.

    The first is “Writeln”. (”l” is “L” not “i”) This function types what you insert between “('')” in the Debug Box. (lower screen of Scar) This function is used to display the script user with information like how long the script has been running. We will learn to do this in the “Other” section of this tutorial.

    Next we have “Wait”. Refer to the above function description if you have not yet.

    Finally we have “SendKeys”. This function will serve you in your first few scripts where you will probably create an auto-talker.

    The function types whatever you place between “('')” into the text box you are currently focused on. With Scar, you may have to set the Client Window on the text box.

    Now you may wonder how you make the function press enter. This is very simple.

    This is an example:
    SCAR Code:
    program TypeExample2;

    begin
      SendKeys('Hello'+chr(13));
    end.

    As you can guess, “chr(13)” represents the key “enter”.



    <Color>

    This is an example:
    SCAR Code:
    program FindColorExample1;

    var
    x,y: Integer;

    begin
      FindColor(x,y,293419,577,7,727,163);
    end.

    Oh, don’t get scared now. Let’s take this step by step.

    This function finds the color that you tell it to find (“293419” in this example) and saves the place where it found the color in “x,y”.

    The “x,y” in the function are just empty integers that are waiting to be filled with the location in which the color is. To use this function you would have to tell the program that x and y are integers as I have done at “x,y: Integer;”.

    Next we have the color number. (293419) The color number can be replaced by a constant as you have learned in your previous lessons.

    Finally there is “577,7,727,163”. This goes all the way back to the first lesson. This part of the function tells Scar where to look for the color. “577,7” are the coordinates for the top left corner and “727,163” are coordinates for the bottom right corner of the square in which Scar looks for the color.

    “FindColor” looks for the color from the top left corner to the lower right corner of the square you tell it to look in. To understand this, let’s take a look at this example.

    Let’s say that you want to look for color “242” in “0,0,100,100”. Now there are two objects in between those coordinates.

    The first object had the color 242 and is at the coordinates 25,30. The second object had the same color of 242, but was at the coordinates 75,80. Which object do you think Scar will go to first? It will go to the first object, because it searches from the top left corner to the bottom right corner.

    Here is another function to do with color.

    This is an example:
    SCAR Code:
    program FindColorExample2;

    var
    x,y: Integer;

    begin
      FindColorSpiral(x,y,293419,577,7,727,163);
    end.

    This function is the same as FindColor, except that it is used to find colors that take up a lot of space.



    <Mouse>


    This is an example:
    SCAR Code:
    program MoveMouseExample1;

    begin
      MoveMouse(25,250);
      Wait(100);
      ClickMouse(25,250,true);
    end.

    This example moves the mouse to the coordinates 25,250 and then clicks there.

    “MoveMouse” moves the mouse to the coordinates you place between “()”.

    Refer to a previous lesson for the “Wait” function.

    “ClickMouse” clicks the mouse at the coordinates you place between “()”. The “true” stands for clicking the left mouse button, while if you put “false” in that position Scar will right-click.

    true = left mouse button
    false = right mouse button

    This is an example:
    SCAR Code:
    program MoveMouseExample2;

    begin
      MoveMouse(25+random(2),250-random(20));
    end.

    Here you see that I have added randoms to the coordinates. Yup! You can do that.

    “25+random(2)” will tell Scar to move the mouse anywhere from 25-27 for the coordinate x and “250-random(20)” will tell Scar to move the mouse anywhere from 230-250 for the y coordinate.


    Let’s explore some other forms of the function “MoveMouse”.

    This is an example:
    SCAR Code:
    program MoveMouseExample3;

    begin
      MoveMouseSmooth(25,250);
    end.

    This function works the same as “MoveMouse” except that it moves it slower and softer. Experiment with it to see the difference.

    This is an example:
    SCAR Code:
    program MoveMouseExample4;

    begin
      MoveMouseSmoothEx(25,250+random(0),20,40,45,25,20);
    end.

    This function is the same as “MoveMouseSmooth” except that it moves the mouse more humanlike. The last part that starts with “+random” are options for humanlike response. Press F1 in Scar and scroll down to MoveMouseSmoothEx to see the options for this.


    Let’s explore a few other forms of the function “ClickMouse”

    This is an example:
    SCAR Code:
    program ClickMouseExample1;

    begin
      HoldMouse(25,250,true);
      Wait(100);
      ReleaseMouse(25,250,true);
    end.

    “HoldMouse” clicks and holds the mouse as clicked. This is good if you want to highlight something with the mouse. “true” stands for the left mouse button. “false” in that position would tell Scar to right click and hold.

    Refer to a previous lesson for description of “Wait” function.

    “ReleaseMouse” works alongside “HoldMouse” and releases the mouse from being held as clicked. “true” acts the same as in “ClickMose” and “HoldMouse” functions.


    Now let’s combine our knowledge and use a color function with a mouse function.

    This is an example:
    SCAR Code:
    program CombineExample1;

    var
    x,y: Integer;

    const
    MonsterColor = 293491;

    begin
    if(FindColor(x,y,MonsterColor,0,0,100,100)) then
     begin
      MoveMouseSmoothEx(x,y +random(0),20,40,45,25,20);
      Wait(100+random(10));
      ClickMouse(x,y,true);
     end;
    end.

    Look over this example carefully. In this example, Scar does the following: If it finds the “MonsterColor” then it will move the mouse to the coordinates of where it finds the color and then click at those coordinates.

    As you have learned in the description of “FindColor”, x and y in the function store the coordinates in which the color is found. If the color is found, the coordinates are stored in x,y and we can use them to tell Scar where to click.



    <Bitmap>


    If you do not know, bitmap is an image type. Sometimes in a script you want the compiler (Scar in this case) to find an image instead of a color. That is what you would use the following for.

    If you have the image of the object you wish to find, you must convert it to bitmap file type. Search http://www.google.com to find a free program that does this for you.

    Next, Scar requires you to place the image on a black background. Thus, only the object you wish to find is looked for and not the background as well. Open paint or any other image editing tool and paint the background black. As well as this, make the object centered so that it is in the center of the black background. Also, make the image as small as possible while still capturing your whole object.

    Now save it and we will continue learning how to use it.

    Ok, now open Scar and follow these steps.

    On top of the there is a toolbar with “File, Edit, View, etc.”

    1. Click Script and then click on Picture to String.
    2. A window will pop up
    3. Click Open
    4. Open the bitmap you want to use
    5. Click Paste
    6. Click OK
    7. Look on the bottom in the Debug Box and you will see a code something like-

    SCAR Code:
    Fish := BitmapFromString(8, 11, 'z78DA33302007B801C16015C7C5A6A' +
           '77A62F4E252894CD21F0000D64369E1');

    -Except it will most likely be much longer.
    “Fish” in this example is the name of the bitmap.

    8. Now we will need to create a variable for the bitmap.

    This is an example:
    SCAR Code:
    program BitmapExample1;

    var
    Fish: Integer;

    begin
    end.

    As you see, you must declare the bitmap as an integer before using it.

    9.Now we must load the bitmap at the beginning of the script.
    This is an example:
    SCAR Code:
    program BitmapExample2;

    var
    Fish: Integer;

    begin
      Fish := BitmapFromString(8, 11, 'z78DA33302007B801C16015C7C5A6A' +
           '77A62F4E252894CD21F0000D64369E1');
    end.
    That is how you. You don’t necessarily have to do this in the beginning. You could load the bitmap right before you use it. If you do, however, wish to just load all your bitmaps in the beginning, it is better to create a procedure with all the bitmaps loaded in it.

    This is an example:
    SCAR Code:
    program BitmapExample3;

    var
    Fish: Integer;

    procedure LoadBmps;
    begin
      Fish := BitmapFromString(8, 11, 'z78DA33302007B801C16015C7C5A6A' +
           '77A62F4E252894CD21F0000D64369E1');
    end;

    begin
     LoadBmps;
    //Do whatever
    end.

    As you see, I loaded the bitmap in the procedure and then just included the procedure in the final part of the script.

    The function “FreeBitmap” releases the loaded bitmap.

    This is an example:
    SCAR Code:
    program BitmapExample4;

    var
    Fish: Integer;

    procedure LoadBmps;
    begin
      Fish := BitmapFromString(8, 11, 'z78DA33302007B801C16015C7C5A6A' +
           '77A62F4E252894CD21F0000D64369E1');
    end;

    procedure FreeBmps;
    begin
      FreeBitmap(Fish);
    end;

    begin
     LoadBmps;
    //Do whatever
     FreeBmps;
    end.

    You see, the trouble with bitmap is that it uses up memory. On a low memory computer, this will slow it down greatly. Try avoiding using bitmaps as much as possible.

    Alright, now that you know how to load a bitmap, let’s learn how to use it.

    This is an example:
    SCAR Code:
    program BitmapExample5;

    var
    Fish: Integer;
    x,y: Integer;

    procedure LoadBmps;
    begin
      Fish := BitmapFromString(8, 11, 'z78DA33302007B801C16015C7C5A6A' +
           '77A62F4E252894CD21F0000D64369E1');
    end;

    procedure UseBitmap;
    begin
    if(FindBitmap(Fish,x,y)) then
     begin
      MoveMouseSmoothEx(x,y+random(0),20,40,45,25,20);
      Wait(1000+random(100));
      ClickMouse(x,y,true);
     end;
    end;

    procedure FreeBmps;
    begin
      FreeBitmap(Fish);
    end;

    begin
     LoadBmps;
      UseBitmap;
     FreeBmps;
    end.

    As you see, “FindBitmap” is the function to find the bitmap on the whole screen. This function searches the whole screen. “Fish” in the example is the bitmap name that you want to find. “x,y” is where the coordinates of the bitmap will be stored.

    As in FindColor, FindBitmap looks from the top left corner to the bottom right corner.

    The other version of “FindBitmap” is “FindBitmapIn”. “FindBitmapIn” is the same as “FindBitmap” except that you set the box where Scar looks in.

    This is an example:
    SCAR Code:
    program BitmapExample6;

    var
    Fish: Integer;
    x,y: Integer;

    procedure LoadBmps;
    begin
      Fish := BitmapFromString(8, 11, 'z78DA33302007B801C16015C7C5A6A' +
           '77A62F4E252894CD21F0000D64369E1');
    end;

    procedure UseBitmap;
    begin
    if(FindBitmapIn(Fish,x,y,0,0,100,100)) then
     begin
      MoveMouseSmoothEx(x,y+random(0),20,40,45,25,20);
      Wait(1000+random(100));
      ClickMouse(x,y,true);
     end;
    end.

    procedure FreeBmps;
    begin
      FreeBitmap(Fish);
    end;

    begin
     LoadBmps;
      UseBitmap;
     FreeBmps;
    end.

    As you see, FindBitmapIn just adds the last part. The coordinates 0,0 to 100,100 is where Scar will look for the bitmap “Fish”.


    <Other>


    This is an example:
    SCAR Code:
    program DebugExample1;

    begin
      ClearDebug;
    end.

    “ClearDebug” clears the debug box on the bottom of Scar.

    This is an example:
    SCAR Code:
    program IntToStrExample1;

    var
    i: Integer;

    begin
     i:=0;
      Writeln('i is ' +IntToStr(i) +'.');
    end.

    “IntToStr” takes the integer you put between “()” and places its value into what you want to type out. This is good in creating progress reports.



    --Random--


    Randomization is essential to RuneScape and many other game cheating. Randomizing wait times and clicking location makes the macro seem more human.

    Even if you intend to spend your time scripting for things other than macroeing, randomization will help you.

    This how to randomize a “Wait” function:
    SCAR Code:
    Wait(1000+random(100));

    Scar will now wait anywhere from 1000 to 1100 seconds.

    This is how to randomize “MoveMouse” function:
    SCAR Code:
    MoveMouse(25+random(2),35-random(10));

    Scar will now move the mouse anywhere from 25 to 27 for x coordinate and 25 to 35 for y coordinate.

    This is how to randomize an integer:
    SCAR Code:
    program RandomIntegerExample;

    var
    i: Integer;

    begin
     i:=random(5);
      Writeln('i is ' +IntToStr(i) +'.');
    end.

    Try this example out. You will see that i will now vary and randomly be anywhere from 0 to 4. The thing you have to remember about randomizing integers is that it will be 0 to the number before what you put. So if you put “i:=random(10);” then i could be 0 to 9, but it can not be 10.



    --Loops/Until--


    Have you ever wondered, “How does the script keep going after it’s done something once?”

    This is what programmers call “loops”. If someone refers to a loop it means that the program starts from a position where you tell it to start again from. Let’s see how to set loops up.

    This is an example:
    SCAR Code:
    program LoopsExample1;

    var
    i: Integer;

    begin
     i:= 0;
    repeat
      i:= i + 1;
      Writeln('This will go on 10 times.');
    until(i >= 10);
    end.

    As you can see, first we state that i is 0. Then we type repeat. Then we tell Scar that every time a loop is done, it will add 1 to i. After this we tell Scar what actions to perform. Finally, you place “until” and between “()”, you write “i>=” and the number of loops you want Scar to go through. (How many times you want it to do what you put between repeat and until)

    Along with this, you can make Scar repeat forever. (until you press stop or press ctrl+alt+s)
    To do this follow this example:
    SCAR Code:
    program LoopsExample2;

    begin
    repeat
      Writeln('This will go on forever.');
    until(false);
    end.

    As you can see, to tell Scar to repeat forever, all you need is "repeat" at the beginning and "until(false)" at the end.

    You can also use this repeat/until process to tell Scar to stop when something happens.

    This is an example:
    SCAR Code:
    program LoopsExample3;

    var
    i,x,y: Integer;

    begin
     i:= 0;
    repeat
      i:= i + 1;
    if(FindColor(x,y,10023,0,0,100,100)) then
     begin
      MoveMouseSmoothEx(x,y+random(0),20,40,45,25,20);
     end;
    until(not(FindColor(x,y,10023,0,0,100,100)));
    end.

    As you see here, I told Scar to find the color and move the mouse over it. It will keep doing this until it does not find the color.


    +--------------------- [The Middle] ---------------------+




    +--------------------- [Finalization] ---------------------+


    --Includes--


    Remember in the beginning when we were talking about procedures? Well, this is the reason why. “Includes” is a way to use these procedures in other scripts so you don’t have to rewrite them.
    Follow this layout to use includes:
    SCAR Code:
    program IncludesExample;

    {.include Miner.scar}

    //rest of the scripts

    One thing you must know, is that to use includes, they must be in either the same folder as the script you’re creating or the “Includes” folder in the Scar directory. (Where you installed Scar to)

    You do not need to have them there, but if you do not then you have to write out the whole destination after “.include “.

    All includes must go after program and before anything else.

    The most common of all includes is SRL. This SRL was created by expert programmers to make your work easier. Includes will help you greatly when you become more experienced with Scar, but for now just ignore them.



    --Good Luck--


    Now that you have read this whole tutorial, you must be tired. Rest and then try to make a few simple scripts using the functions I provided for you. If you want to dig deeper into functions (I have not explained every single function) then press F1 while in Scar.

    I hope this tutorial has helped you. If you find anything confusing or wrong please tell me by emailing me at WhoCares_357@yahoo.com or posting in a thread if this tutorial is in one. If you want some help I might also be able to assist you. I am sorry if I delay in answering you, for I may be busy at the time. Thank you and good luck in your scripting career.


    +--------------------- [Finalization] ---------------------+

    ================================================== =============
    Last edited by WhoCares357; 12-02-2010 at 01:12 AM.

  2. #2
    Join Date
    Dec 2006
    Posts
    374
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thx for this script! it really helped me out! very cleanly written and explains things well. nice job!
    Another awsome scripting forum! Check it out: www.Uberbroproductions.net/forums
    TRY MY VARROCK ZAMMY MAGE CURSER/CONFUSER/WEAKENER! THE LINK IS BELOW
    http://www.srl-forums.com/forum/varr...56.html?t=6356
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~


  3. #3
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank You.

  4. #4
    Join Date
    Dec 2006
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    this was a great help to me thank you

  5. #5
    Join Date
    Jan 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you! You just boosted my Knowledge from .0005% to 20%! This TUT is awesome very detailed ( The way i like tuts ) and helps out alot!!

    Shot_j00

  6. #6
    Join Date
    Oct 2006
    Posts
    702
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    awesome tut i read it all in one sitting. i understand scar that much more!

  7. #7
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for feedback guys. I fixed a few errors in the script examples.

  8. #8
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you soo much for making this [TUT]!

    It helped clear up alot of problems I was having.

    I highly reccomend this for anyone who wants to learn to script.

  9. #9
    Join Date
    Mar 2006
    Posts
    82
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Very nice, well structured and very informative.

    10/10, keep up the nice work

    -Mad Cow
    ---- On holidays till 4th Janurary ----

  10. #10
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    stickyfied.
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  11. #11
    Join Date
    Jan 2007
    Location
    La Jolla,CA
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ty for this i managed to build my first script its in rs non srl scripts section!!!!

  12. #12
    Join Date
    Jan 2007
    Location
    La Jolla,CA
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    is there any srl tutorials???

  13. #13
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Idk, I would like to look at one myself. If you find one, please pm me.

  14. #14
    Join Date
    Jun 2006
    Location
    USA
    Posts
    1,828
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I really like this tutoial, very easy to understand for people who are learning scar scriptin. Good work.

  15. #15
    Join Date
    Mar 2006
    Location
    USA
    Posts
    948
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Wow, this is big! It needs chapters :S

  16. #16
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for all the feedback guys. I made this guide for the public, and I am glad that the majority appreciate it.

  17. #17
    Join Date
    Jun 2006
    Location
    Tennessee, USA
    Posts
    2,603
    Mentioned
    1 Post(s)
    Quoted
    46 Post(s)

    Default

    hey thanks man this helped me tons!

  18. #18
    Join Date
    Jan 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ty its very helpful

  19. #19
    Join Date
    May 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great Tutorial! you++

  20. #20
    Join Date
    Jun 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the information, I will hopefully try to use it to a good macro (is that an oxymoron?)

  21. #21
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by wstephen4 View Post
    Thanks for the information, I will hopefully try to use it to a good macro (is that an oxymoron?)
    Lol, it kinda is since macros are against the rules.

  22. #22
    Join Date
    Feb 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default hey, just wanted to let you know

    This tutorial is 100% useful, it really answered ALL my questions... every time I was like "what about when this happens" you jumped right onto it.

    you'll be seeing some newbie scripts soon.

    its not the first time scripting in general but this is the most complex scripting i've ever encountered. Although it resembles alot like programming.

    thanks again!

  23. #23
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Glad I could help.

  24. #24
    Join Date
    Jan 2007
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    As you can see, this coordinate is 5 to the right of 0, and 25 up from 0.
    would that be down? instead of up?

    nice guide

  25. #25
    Join Date
    Dec 2006
    Location
    SC
    Posts
    692
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Mithril Fish View Post
    would that be down? instead of up?

    nice guide
    Thanks.(I fixed it) I'm always looking for little mistakes . If you see anymore please tell.

Page 1 of 20 12311 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unmatched Beginner's Guide To Scripting Scar (Hands On)
    By WhoCares357 in forum Outdated Tutorials
    Replies: 44
    Last Post: 09-02-2010, 09:39 PM
  2. UnRivaled Guide To Scripting
    By pwnaz0r in forum OSR Intermediate Scripting Tutorials
    Replies: 119
    Last Post: 11-08-2008, 11:00 PM
  3. All In One Beginner's Guide To Scar Scripting
    By xaviar in forum Outdated Tutorials
    Replies: 4
    Last Post: 07-05-2008, 10:11 AM
  4. Best scripting guide?
    By Conman3030 in forum OSR Help
    Replies: 5
    Last Post: 11-30-2007, 11:07 PM
  5. Guide to Scripting(If you are totally new at it)
    By WhiteShadow in forum Outdated Tutorials
    Replies: 6
    Last Post: 06-01-2006, 04:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •