Page 1 of 2 12 LastLast
Results 1 to 25 of 45

Thread: Unmatched Beginner's Guide To Scripting Scar (Hands On)

  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 (Hands On)

    Unmatched Scar Scripting Tutorial for Beginners (Hands On)

    by WhoCares357


    <><><><><><><><><><><><><><>
    ---Created by WhoCares357---
    <><><><><><><><><><><><><><>


    Table of Contents

    -Overview
    -Syntax
    -Basics
    -Variables
    -Constants
    -Loops
    -Procedures
    -If, Then, Else
    -Few Extras And Good-Bye


    <Overview>

    I have created a second tutorial to better teach people to script Scar. I gathered an idea while teaching a few people over msn. Instead of explaining all that complicated, boring stuff in the beginning, I will now guide you along a route to learn easier. In this tutorial, it is necessary to acquire Scar 2.03 or later version. You can acquire this software at www.dylock.net/scar.

    If you are entirely new to Scar, I suggest that you read the Scar Info chapter in my other guide found at http://www.villavu.com/forum/showthread.php?t=4625.

    I will not bother with an introductory. (This could be considered one.) You should have read enough guides by know to know that to script you need patience, neatness, etc. If you are following this tutorial, I would advise you to look over my other guide found at http://www.villavu.com/forum/showthread.php?t=4625. If you get stuck or confused, refer to that. It may clear up some of your problems.

    Alright, enough with that boring stuff; let's get to scripting!

    <Syntax>

    When you open up Scar, it will most likely prompt you to download includes. Just press yes and wait for it to download them. After this is ready, you will notice two text boxes. The larger one on top is where we write the script. The bottom one is used with special functions. (We will go over them very shortly.)

    Look in the top text box. You will see this:

    SCAR Code:
    program New;
    begin
    end.

    This is the default text that appears every time you open Scar. I'll explain it briefly. (Refer to my other guide for full explanation)

    “New” is the name of your script. The line “program New” is not even necessary. It just tells the user the name of the script. If you want to rename it, there are a few rules:

    1. You must leave a space after “program” followed by the name.
    2. The name must be a single word. It may not have any spaces.
    3. The line must end with ; (; ends most lines)

    If you don't want to bother with the name for now, just delete line 1.

    Now we see:
    SCAR Code:
    begin
    end.

    This is called the main loop. The main loop is just a fancy word for a simple definition. The main loop is where you tell Scar what to do. If you put anything outside of “begin” “end.”, it will show up as an error.

    There are a few rules for the main loop:

    1. Every begin must have an end. (You will understand this later)
    2. The last end always has a dot after it.

    If you get an error, refer to these rules for clear-up.

    Enough with all the talking; let's start scripting.


    <Basics>


    Your First Script

    1. Make a blank line between “begin” and “end.”
    2. Type in: “MoveMouse(125,100);” (without quotes)

    Your script should now look something like this:

    SCAR Code:
    program IAmAScripter;
    begin
      MoveMouse(125,100);
    end.

    3. Press play and let go of your mouse.

    You should have seen your mouse move by itself. If you received an error, compare your script to my example.

    “MoveMouse” is called a function. It tells Scar what to do. “125,100” are coordinates. If you do not know how coordinates work on your computer, refer to my other guide. (You can find the link on top of the page). Also you notice the “;” at the end of the line. This tells Scar to stop right there and not read the rest of the line. Placing “;” at the end of lines isn't necessary, but is recommended.

    4. Try to change the coordinates and press play. (Use the pen/pipette in the Scar toolbar to pick a specific coordinate point.)

    WARNING!
    Do NOT place a coordinate that is greater than your screen resolution. If your resolution is 800,600 and you tell Scar to “MoveMouse(1000,1000);”, it will continually keep searching for the coordinates that don't exist and your mouse will go crazy. You will most likely need to restart your computer then.


    5. Copy the example over your old script: (Save the old one for reference if you want)

    SCAR Code:
    program IAmAScripter;
    begin
     MoveMouse(100,100);
     Wait(1000);
     ClickMouse(100,100,true);
    end.

    Here are two new functions. The first is “Wait”. As you may guess, that function waits. “1000” is the number of milliseconds to wait.

    REMEMBER!
    1000 milliseconds = 1 second


    The next function is “ClickMouse”. Once again, you don't have to be a genius to figure out that that function clicks the mouse. The coordinates tell Scar where to click. “true” at the end tells Scar to click the left mouse button.

    REMEMBER!
    true = left mouse button
    false = right mouse button


    6. Play around with the coordinates and wait time. (Don't forget the “WARNING” and “REMEMBER”)
    7. Copy the following over your old script: (Or add on)

    SCAR Code:
    program IAmAScripter;
    begin
     MoveMouseSmooth(200,200);
     Wait(100);
     HoldMouse(200,200,true);
     Wait(10);
     ReleaseMouse(200,200,true);
    end.

    First off you will see “MoveMouseSmooth”. This function is similar to “MoveMouse”, but it moves the mouse slower.

    “HoldMouse” and “ReleaseMouse” work together most times. “HoldMouse” holds the mouse down at the coordinates said. It will not release the mouse until you tell it too. That is where “ReleaseMouse” comes into play. “ReleaseMouse” must have the same coordinates and the same mouse button (true/false) as “HoldMouse” to release the hold.

    These two functions have two uses. The first is that you can drag and highlight multiple objects. The second reason is that it clicks the mouse in a less detectable fashion than “MoveMouse”. Thus, it reduces the chances of getting caught by macro detection software.

    8. Play around with the coordinates, wait times, and the mouse button to click. (true/false in “ClickMouse”)
    9. Copy the following example over your old script: (or add on)

    SCAR Code:
    program IAmAScripter;
    begin
     ClearDebug;
     WriteLn('"Hello World!" gets annoying. ');
     WriteLn('Hello World! ');
    end.

    First there is “ClearDebug;”. This function clears the lower text box of Scar. (Debug Box)



    “WriteLn” is a new kind of function. “WriteLn” is a function that produces text. After you run the example, look on the bottom text box in Scar. You will see the text you typed between “''” appear there. Each “WriteLn” creates a separate line in the Scar debug box. (Lower Text Box)

    REMEMBER!
    Text functions always have '' to indicate where the text starts and ends. You will see the text appear pink. The text (words) that appear pink is the text that will be typed.


    10. Play around with this a little.
    11. Copy the following example over your old script: (or add on)

    SCAR Code:
    program IAmAScripter;
    begin
     SendKeys('Now this is more like it!'+chr(13));
     Wait(100);
     SendKeys('I can now spam my friends through msn.');
     Wait(100);
     SendKeys(chr(13));
    end.

    WARNING!
    Click in a blank text area before starting the script. It will type wherever the cursor is. (ctrl+alt+r to run without pressing mouse)


    The new function is “SendKeys”. This function compares closely with the “WriteLn”, but has a much more dramatic effect.

    “SendKeys” actually types the text you tell it to type in the location where the cursor (black blinking marker) is. You will also notice something different between “SendKeys” and “WriteLn”. This is “chr(13)”. “chr(13)” tells Scar to press enter.

    I showed you two ways to add it in. The first is to include it in the same line as the text you want it to type. To do this, you must add a + after the closing (') of the text about to be typed and then place “chr(13)”.

    The second way is to just add it on a separate line. To do this, don't include “''” in the function. Just type chr(13) between ( ).

    WARNING!
    ALWAYS include “Wait” functions in your script. (Especially between typing functions like SendKeys) This will prevent heavy lag and risky malfunctions.


    12. Play around with this a little. (Spam out your friends :p)
    13. Try to create a script with as minimum of “looking back” as possible. Practice until you believe that you understand the functions and how to use them without many problems.

    Remember, this isn't school. You CAN have fun while learning. By experimenting, you will learn common errors and prevent them in the future. My closing for your first script is to say, “Remember the WARNING's and REMEMBER's that I placed to avoid implications.”




    <Variables>


    Our next view point will be variables and constants. I would highly advise you to at least look over that section in my other guide. I will only explain it briefly, and will drown you with examples.

    Variables and constants store data. This is the same as saying that they represent certain numbers or characters. Variables can be changed during the script, while constants will always be the same. You will see this through some of my examples.

    First we declare the variable. (Tell Scar that we are using the name as Integer, String, or Boolean).

    1. Copy down my example.

    SCAR Code:
    program Vars;

    var
    i, sum: Integer;
    Hello: String;

    begin
    //In the next example
    {I will explain how to use it}
    end.

    2. Study the example.

    In this example, there are 2 types of variables: integers (whole positive and negative numbers) and strings (any characters; AKA: what you use as text for SendKeys. We will touch booleans (true and false) later. If you are very confused and have already read the section in my last tutorial, then bear with me a little.

    In my example I used i and sum as integers and Hello as a string. You can name your variables anything you want. You can also declare more than one of the same variables (if they're of the same kind: integers, strings, etc.) on the same line; just separate them with a comma.


    EXTRA!

    I used // and { } for commenting. In scar, those will appear green. There are two ways to use comments. One way is to put // in front of what you want to comment. This will make the rest of the line a comment. The other way is to use { }. Whatever is between { } will be a comment. Comments are used to leave yourself notes or directions for the user of your script.

    3. Copy the following example.

    SCAR Code:
    program Vars;

    var
    i, sum: Integer;
    Time: Integer;

    begin
     i:= 1;
     sum:= i+1;
     WriteLn('The sum is ' + IntToStr(sum));
     Time:= 100;
     Wait(Time);
    end.

    4. Study the model.

    You should already know how to tell Scar which variables to use. (i: Integer;) Now you can see how to tell Scar what the integer is. In this example I made scar see i as 1 (i:= 1;). Then, I told Scar that sum is equal to whatever i is equal to, plus one (sum:= i+1;).

    Then, I told Scar to print out, in the debug box, what the integer sum is. To do this, I used a new function called IntToStr. IntToStr can be added to WriteLn, SendKeys and other typing functions. You must put the integer (in this case “sum”) between ( ) after IntToStr to indicate which integer to use.

    After this, I told Scar what the integer Time was. Time:= 100;. Now look at the next part. You see how I replaced the amount to wait (Like Wait(100) ) with the integer Time. Because I told Scar that Time is 100, Scar sees Time as 100 anywhere I put it. You can do this with many other commands. MoveMouse or ClickMouse are just a few that you can use that with.

    5. Play around with variables for a bit. You will discover that you can use Scar as a virtual calculator.

    REMEMBER!
    + = add
    - = minus
    * = multiply
    / = divide



    EXTRA!

    Randomizing your script is essential to macro on RuneScape. To randomize something, you would type +random(n) after a number you want to randomize. n would be the amount to randomize. Here's an example.

    SCAR Code:
    program Randoms;

    var
    i: Integer;

    begin
    i:= 3+random(5);
     WriteLn(IntToStr(i));
     Wait(200+random(100));
     MoveMouse(2+random(4), 6-random(4));
    end.

    I first told Scar that i is going to be an integer. Then I said that i is 3 and a random of 0-4 added onto it. Then we told Scar to write what i is in the Debug Box. Next, we told Scar to Wait 200 milliseconds and a random of 0-99 milliseconds added on to that. Finally, we told Scar to move to the coordinates of 2 and random of 0-3 added for x, and 6 and random of 0-3 subtracted for y.

    6. Try to randomize some of your scripts.


    Now let's see how to use strings.

    As we said before, strings are characters (text).

    7. Copy the following example.

    SCAR Code:
    program Vars;

    var
    Hello: String;

    begin
     Hello:= 'How is everyone doing?';
     WriteLn(Hello);
     Hello:= 'Hi';
     WriteLn(Hello);
    end.

    8. Study the model.

    As you can tell, strings are pretty much used the same as integers, except they are used with typing functions (WriteLn). I first declared Hello as a String. (Hello: String;). I then said that Hello:= 'How is everyone doing?';. Now wherever I put Hello, Scar will see it as 'How is everyone doing?'. I told Scar to print whatever Hello is inside the Debug Box. Next, I renamed Hello and made it something else. This can be done with integers also.

    Remember how I said that variables are special because you can change them inside the script? Well, this is it. All you do is tell Scar that Hello represents something else from now on.

    9. Play around with the concept of Variables. Try incorporating it in your old scripts, or making a new one to test how much you have learned.

    <Constants>

    Once you master Variables, Constants should be a piece of cake.

    As you have learned in your lesson with variables, Scar uses names to represents things like text or numbers. You also learned that variables can be changed throughout the script.

    This is where constants are different. You can only tell Scar what a constant represents once, at the beginning of your script. This is very good to give the user of your script options like wait times, text to type, and color numbers to search for (we will learn colors later).

    This is how we declare constants (Tell what they represent)

    1. Copy the following example.

    SCAR Code:
    program Constants;

    const
    WaitTime = 100;//Time To wait
    WhatToType = 'Hello, I am cool.';//What to type

    begin
    Wait(WaitTime);
    WriteLn(WhatToType);
    end.

    2. Study the script for a while.

    We declare constants after the program Name and before begin. Unlike variables, we tell Scar what constants represent right away (WaitTime = 100;). Then, we use them the same way that we use variables.

    I this example I made Scar wait whatever WaitTime stood for. Then, I made it type whatever WhatToType stood for inside the debug box.

    You see! Once you understand variables, constants come natural. ;)

    3. Incorporate Variables and Constants into your older scripts or make a new one to see how much you have learned.

    REMEMBER!

    Variables can be changed throughout the whole script.
    Constants can only be declared once. You may not change it within the script.


    <Loops>

    By now you must be wondering, “But how do they make the script run forever?”

    I will teach you how to “loop” your script in this section. This will allow your script to run forever or as many times as you will it.

    Let's look at an example.

    1. Copy the following example.

    SCAR Code:
    program Loops;

    begin
      repeat //Place repeat before what you want to repeat
      WriteLn('I want to wait forever!');
      Wait(100);
      until(false); //Place where you want repeat to stop
    end.

    2. Study the model a little and try to run it on your own, personal Scar client.

    Here you see your first loop. There are many different kinds of loops. This is the first and simplest loop we will look at.

    To start this loop, we place repeat before what we want the script to repeat. After we finish writing the commands we want Scar to repeat, we put an until.

    Until has options. The option we used this time was until(false);. This tells Scar to go on forever. The only way this script will stop is if you press stop.

    Remember how I said that you put repeat before what you wanted the script to repeat? I'll show you an example to further that a little further.

    3. Add this onto the old example or just copy paste over the old one.

    SCAR Code:
    program Loops;

    begin
     ClearDebug; //Scar will only do this once
      repeat //Place repeat before what you want to repeat
      WriteLn('I want to wait forever!');
      Wait(100);
    until(false); //Place where you want repeat to stop
     WriteLn('I guess this will never be written, since the above loop goes forever :/');
    end.

    4. Study what I have added and notice the differences between the earlier scripts.
    5. Run the script and discover how it is different from the last one.

    In this example, I told Scar to ClearDebug (Clear Debug box) before starting the loop (repeat). Then I told Scar to WriteLn and Wait. I told Scar to never stop repeating what is between repeat and until by telling it until(false);.

    As you can see, you do not have to have repeat at the beginning of your script. Just set it wherever you want it to repeat from.

    You're probably pretty edgy on seeing that last WriteLn being shown now, eh? ;) Don't worry, with this next part, your loop doesn't have to go forever.

    You must remember how to use variables for this next part. This part should be pretty simple.

    6. Copy down the following example.

    SCAR Code:
    program CountingLoops;

    var
    i: Integer;

    begin
     ClearDebug;
     i:= 0;
    repeat
      i:= i + 1;
      WriteLn('This is loop number ' + IntToStr(i));
      Wait(100);
    until(i = 2);
     WriteLn('Thought you''d never see me, huh?');
    end.

    7. Study the example a little.

    As I warned you, we use integers for loops that go an amount of times. For this example, I chose an integer named i. I first told Scar to ClearDebug. I then said that i is 0. Next, I said that the loop will begin here.

    Now you see the i:= i + 1; after repeat? Since i is 0, we have just added one to 0, thus making i 1. (Since i=0, 0+1=1)

    The reason I told Scar that i is whatever number i represented before plus one, is to count the amount of loops the script has gone through (How many times it has gone from repeat to until). Then, I told Scar to do a bunch of stuff (WriteLn and Wait).

    The next part is what makes this script work the amount of times you want it to. Remember that in our last script we used until(false); to tell Scar to never stop the loop. Well, this time we gave Scar another condition. We told Scar to repeat the loop until i is 2.

    You see! That is how our earlier integer, i, ties into this. Since, it constantly adds one to itself with every loop it goes through, Scar will stop the loop when i becomes 1.

    Finally, we can see the WriteLn we could not see before. I guess the little bugger learned a way to show up, now. :p

    REMEMBER!

    = - Equal to
    < - Greater than
    > - Less than
    <= - Greater than or equal to
    >= - Less than or equal to
    <> - Not equal to


    Use those with to tell Scar when to stop loops (until(i > 4);).

    8. Play around with the repeat loop for a little while. When you're ready, continue to the next part.


    I won't explain the next part too much. I told you earlier that there are different kinds of loops. I will show you a few of these through examples. Try to study the examples a little before going away disappointed :).

    SCAR Code:
    program OtherLoops;

    var
    i: Integer;

    begin
    i:= 0;
     while(i < 6) do
      i:= i + 1;
      WriteLn('Hullo number ' + IntToStr(i));
    end.

    Simply put, it goes like this. I made i 0. I told Scar while i is less than 6, make i equal itself plus one and WriteLn.

    SCAR Code:
    program OtherLoops;

    var
    i: Integer;

    begin
    for i: = 0 to 5 do
     i:= i + 1;
     WriteLn('Loop number ' + IntToStr(i));
    end.

    This loop works like this. i is 0. While i is going from 0 to 5, do the following. Then I made i equal itself plus one and made Scar WriteLn.


    I hope the last two loop types were not too confusing. If you are confused, keep studying the examples. By making scripts that use different kinds of loops, you will learn how to use them.


    EXTRA!

    Sub-Begin and Sub-End;

    This is something that you should learn before we go to the next step.

    In general, there is the main loop. This is the begin end. However, there can be many tiny sections inside the main loop. You might need to separate them to make your life easier while editing scripts. This will also help you later when we learn if then else procedures.

    SCAR Code:
    program SubBeginAndEnd;

    var
    i: Integer;

    begin
     ClearDebug;
     i:= 0;
    repeat
      begin
        i:= i + 1;
        WriteLn('Hi!');
        Wait(100+random(10));
      end;
    until(i = 5);
     WriteLn('That is how we use sub-begin and end.');
    end.

    9. Study this a little.

    You see how I created a small sub-section in the main loop to make my script look neater, and to make that section easier to locate later if I wish to edit my script.

    You can do this anywhere in the main loop, but remember that every begin must have an end. If you have 3 begins and 2 ends, you will get an error. Also remember that every end, except for the last one, will have ; following it.


    <Procedures>

    Procedures become simpler once you see some examples, but just know this: Procedures are used to reduce the amount you have to type out.

    Procedures have their own loop. Remember that Scar will only do what you tell it in the main loop (last begin and end). Procedures have to be called on (Write the procedures name) in the main loop. If you're confused, look at the following example.

    1. Copy this example.

    SCAR Code:
    program Procedures;

    procedure Write; //procedure name (like program name)
    begin
      WriteLn('I love pizza');//what to do in procedure
      Wait(100);
    end;

    begin
      Write; //use the procedure in main loop
    end.

    2. Study this example.

    In this example I made a procedure named Write. You have to name procedures the same way you name the program. Next, I told Scar that the procedure will first WriteLn and then Wait.

    Notice how I made the procedure have its own begin and end.

    Next, I had to include the procedure name in the main loop to tell Scar to do what the procedure does.

    3. Make your own script using a procedure.
    4. Copy the following example.

    SCAR Code:
    program Procedures;

    var
    i: Integer;

    procedure Move;
    begin
       repeat
        begin
          i:= i+1;
          Wait(100);
          MoveMouse(200, 200);
        end;
       until(i = 2);
    end;

    procedure Combine;
    var x: Integer;
    begin
     ClearDebug;
      for x := 0 to 3 do
          x:= x + 1;
          Wait(100);
          WriteLn('Greetings All');
          Move;
    end;

    begin
      Combine;
    end.

    5. Study the example a bit.

    In this example, I used multiple procedures. If you study the first procedure you will see how a procedure is a bit like its own loop. It can have more begin and ends and can have repeating loops. The first procedure Starts a repeat. I told Scar to Wait then MoveMouse. It will do this three times.

    Next you see the procedure Combine. Study it a bit and you will see something strange.

    In this procedure I included a variable inside the procedure. Yup, you can do this. However, since I made the variable only for the procedure, other procedures won't see it. This means that if you included x:= 0 in the main loop or another procedure, Scar would tell you that it doesn't know a variable named x.

    In this script I used a for loop to tell Scar what to do three times. I told it to Wait, WriteLn, and then do whatever Move stands for doing.

    Finally, I included the procedure Combine in the main loop to tell Scar to do whatever Combine does.

    6. Experiment with this a bit. See what you can come up with.


    <If, Then, Else>

    Tired of reading? Well, we're almost at the end here. The last thing we will study is the If, Then, Else statement. This is one of the most important concepts for macroeing.

    Scar uses colors to macro. What it does is this: If FindColor Then MoveMouse(to color). This is what you are about to learn how to do.

    1. Copy down this example.

    SCAR Code:
    program IfThenElse;

    var
    x, y: Integer;

    procedure ClickColor;
    begin
     if FindColor(x, y, 123124124, 0, 0, 100, 200) then
      begin
        MoveMouseSmooth(x, y);
        Wait(100+random(200));
        ClickMouse(x, y, true);
      end else
      begin
        WriteLn('Color Not Found. :/ Sorry');
      end;
    end;

    begin
      Wait(1000);
      ClearDebug;
      ClickColor;
    end.

    2. Study this example a bit.

    You should already know how to make a procedure. The procedure ClickColor does this. It tells Scar: If you FindColor, then MoveMouseSmooth, Wait, and ClickMouse; if you don't find color (end else) then WriteLn.

    Let me explain the FindColor function a little.

    x, y are used to fill where the color is found. For instance, if the color is found at 2, 50, then x will be 2 and y will be 50. The next long number (123124..) is the color number. To get this, use the color picker (ctrl+alt+p) to click on the color you want. It will display the color number in the debug box. 0, 0 are the starting cords at which Scar will start looking for the color. 100, 200 are the ending cords. Scar looks for cords left to right. In this example it would start at the coordinate 0, 0 and search 1, 0 2, 0 3, 0 until x became 100. Then it would go to the next line 1, 1 2, 1 3, 1.

    If, Then, Else statements don't necessarily have to be used for finding colors. Let's look at one that doesn't look for colors.

    3. Copy down the following example.

    SCAR Code:
    program IfThenElse;

    var
    i: Integer;

    begin
     i:= random(4);//will be random 0 to 3
     if (i = 0) then
      begin
        WriteLn('i is 0');
      end else
     if (i = 1) then
      begin
        WriteLn('i is 1');
      end else
     if (i = 2) then
      begin
        WriteLn('i is 2');
      end else
      begin
        WriteLn('i is 3');
      end;
    end.

    4. Study the model.

    Here you see how we use if, then, else statements for every-day stuff. I told Scar that i is a random of 0 to 3. Then, I told Scar if i is 0 WriteLn that i is 0; if i is 1 then WriteLn that i is 1; if i is 2 then...

    This can also be used with constants. For instance, say you give your user an option.

    5. Copy the following example.

    SCAR Code:
    program IfThenElse;

    const
    AmountOfLoops = 3;//How many loops you want do?
    SayStuff = true;//true=say stuff; false=don't say stuff

    var
    i: Integer;

    begin
     repeat
      i:= i + 1;
       if (AmountOfLoops >= 10) then
        begin
          WriteLn('Too many loops. Will not comply.');
          Exit;
        end else
       if (SayStuff = true) then
        begin
          WriteLn('Saying stuff.');
        end;
     until( i = AmountOfLoops );
    end.

    6. Study the model.

    Don't get scared here. I will explain it step by step. First we made two constants. These are options for the user of the script. The first is how many times the person wants the script to run.

    SayStuff is your first glance at a boolean. Remember how a boolean is true or false. That is how you use a boolean. It is the same thing if you want to use it with variables. Just declare it as Name: Boolean; and use it in script as Name:= true;.

    Next we started the script with a repeat. We told Scar if AmountOfLoops is greater than or equal to 10 then to WriteLn that there are too many loops and stop the script (Exit;).

    Then we said if AmountOfLoops is not greater than or equal to 10 (end else) then if SayStuff is true (user wants us to say stuff) then WriteLn. You will see here that I did not use end else here. This is because I don't want the script to do anything if SayStuff = false. In Scar, this is implied if you don't use end else.

    Finally we told Scar to run the script as many times as AmountOfLoops says (i = AmountOfLoops).

    7. Play around with if, then, else statements.


    <Few Extras And Good-Bye>



    If you have read my whole guide and understand most of it, consider yourself on the road to becoming a pro. If you still don't understand most of it, try reading the examples. Play around with them to see how the stuff works.

    I still want to show you something, so don't quit just yet.

    What I will show you is called an include.

    Includes are like procedures. In fact, includes let you use procedures from your older scripts to ease the amount you have to type. This is how to use an include.

    SCAR Code:
    program Includes;

    {.include AutoMiner.scar} //must be after program name and before anything else.

    begin
    //use procedures from AutoMiner script
    end.

    If you just use the name of the file, the script has to be either in the includes folder in the Scar directory or in the same folder as the script you are making. If it is not, you have to write out the whole destination of the script ({.include C:/Folder/Script.scar}).

    A very popular include, which you have probably seen in many modern scripts, looks something like this:

    SCAR Code:
    program Includes;

    {.include SRLSRL.scar}

    begin
    //Use procedures from SRL script
    end.

    The reason the include has two parts to it (SRLSRL.scar) is because the file SRL.scar is located in a file called SRL which is located in the includes file in the Scar directory.

    One more thing. I do not recommend using commands like MoveMouse and ClickMouse on RuneScape. The include called SRL has functions like Mouse and MMouse which are undetectable in RuneScape. I recommend getting SRL from www.srl-forums.com (have to register to download) and learning the commands the come with it.

    I wish you luck on becoming a scripter.
    Last edited by WhoCares357; 05-13-2010 at 01:22 AM.

  2. #2
    Join Date
    Mar 2007
    Posts
    937
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)
    Thank you so much! This tut is the best i've ever seen, you explain it so clear, you're first tut if good as well( i read that one first :P)

    I highly recommend ure tuts to begginers


    Best teacher ever@


    EDIT:first post to

  3. #3
    Join Date
    Mar 2007
    Posts
    937
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Help

    I made a coin picker could you help me out with it please?

  4. #4
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Please no double posting, use the edit button. and just 1 suggestion whocares (of course, I've already told you how this guide got me started in being the best scripter ever, way better then fakawi and wissup (j/k )) In the include section, I'd make the example {.include SRL/SRL.scar} because people maybe able to understand that more and the auto miner include may confuse them.

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

    Default

    Quote Originally Posted by JAD View Post
    Please no double posting, use the edit button. and just 1 suggestion whocares (of course, I've already told you how this guide got me started in being the best scripter ever, way better then fakawi and wissup (j/k )) In the include section, I'd make the example {.include SRL/SRL.scar} because people maybe able to understand that more and the auto miner include may confuse them.
    Alright, will do Mr. JAD. Thanks for the suggestion.

  6. #6
    Join Date
    Mar 2007
    Location
    In your computer
    Posts
    244
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice work i read a few thingz but didnt read everythin, anyways NICE job dude

  7. #7
    Join Date
    Mar 2007
    Posts
    674
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Great job!!!

    love you tutorials

  8. #8
    Join Date
    Apr 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)
    Yet another scripting tutorial....

    And you know what. I like it!!!

    I am a novice scripter myself so i need all the guides i can get...
    thanks and nice post!
    Check out my small guild to making runescape money!!
    http://www.gameolosophy.com/Games/On...pe-Money.23306

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - put this in your sig

  9. #9
    Join Date
    Apr 2007
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    nice tut man , this helped ALOT. ty very much

  10. #10
    Join Date
    Apr 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Wow

    well, i gotta say, possibly best script of the year award for whocares?



    pee.ess
    SCAR Code:
    program Thanks;

    var
    i: Integer;

    begin
     ClearDebug;
     i:= 0;
    repeat
      i:= i + 1;
      WriteLn('THANKS WHOCARES!')
      Wait(200);
    until(i = 15);
     WriteLn('KKEP UP THE GOOD WORK!');
    end.


  11. #11
    Join Date
    Oct 2006
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  12. #12
    Join Date
    Apr 2007
    Posts
    357
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Good job, really useful.

  13. #13
    Join Date
    Feb 2007
    Location
    Australia
    Posts
    176
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well i did like it i made my own autologin reading this but when posted i was told not to use movemousesmooth or findcolor and things like that maybe you could update them eg FindColorTolerance(x,y,color,coords,coords,coords, coords,4)

    Marzy

    -Currently learning script
    Marzey

  14. #14
    Join Date
    May 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)
    Awesome! Just... Awesome! In my opinion, this is by far the best tutorial for beginners! This tutorial was easy to follow, easy to understand, and it's the best place to start. I've learned a lot from this and I recommend this tutorial to everyone who wants to learn how to script. Thanks WhoCares357!

    There is an error though. In the 3rd example under "Loops" (15th out of all), on line 14, there is an apostrophe in the middle of the string and it screws up the whole script.
    SCAR Code:
    program CountingLoops;
     
    var
    i: Integer;
     
    begin
     ClearDebug;
     i:= 0;
    repeat
      i:= i + 1;
      WriteLn('This is loop number ' + IntToStr(i));
      Wait(100);
    until(i = 2);
     WriteLn('Thought you'd never see me, huh?');
    end.
    This is just a small error. I just thought I would point this out because although many will probably spot this error quickly and correct it (like I did ), some people may get confused and frustrated as to why they are getting an error.

    Also, I think it would be a good idea to add a small section that talks about the standards of scripting and how the structure should be ('cause that's important too right?). Again, great tutorial.

    Oh, I also have one question. Includes are written like {.include SRL/SRL.scar}, right? However, there are curly brackets around it. Wouldn't Scar think that this was a comment and leave it out?

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

    Default

    Ay, I'll change right away . Thanks mucho for pointing it out.

  16. #16
    Join Date
    May 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks! Good Tut I learn lots! :P

  17. #17
    Join Date
    Jan 2007
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow this is an amazing tut, i was trying to find a good clear one to start scripting, but this is just immense, thanks!

  18. #18
    Join Date
    Apr 2007
    Location
    NSW, Sydney
    Posts
    45
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

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

    Default

    yep, WhoCares357 i read your guide on sythe a while ago, and it persuaded me to keep trying at SCAR!

    thanks for the amazing guide.

  20. #20
    Join Date
    May 2007
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ugghhhh, i thought learning was fer school lol. i m gona make my own catherby fish/bank script soon...wish me luck!!!

  21. #21
    Join Date
    Jun 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks, Whocares357, your kindness and brilliance are appreciated! It takes a special kind of talent and patience to teach. It is truly a harsh world for someone new to SCAR/SRL and scripting. Your tuts are a soft place to land. I applaude you!

  22. #22
    Join Date
    Jun 2007
    Location
    Pennsylvania
    Posts
    145
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Really nice tut, helped me ALOT. my understanding of scar has just been increased from 7% to 96%. Outstanding guide!

  23. #23
    Join Date
    Jul 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice guide!

    there is an error in this script:

    program Randoms;

    var
    i: Integer;

    begin
    i:= 3+random(5);
    WriteLn(IntToStr(i));
    Wait(200+random(100));
    MoveMouse(2+random(4), 6-random(4));
    end.

    , there should be a bracket where i have highlighted (in red)

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

    Default

    I'll fix it, thanks.

  25. #25
    Join Date
    Jun 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Line 7 in the second OtherLoops example should be as follows:

    for i := 0 to 5 do

    Guess I'm starting to understand this! Thanks Whocares357!

Page 1 of 2 12 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
    By WhoCares357 in forum Outdated Tutorials
    Replies: 482
    Last Post: 04-08-2011, 08:11 AM
  2. Willing to PAY for hands on scripting help.
    By PlAnT in forum News and General
    Replies: 23
    Last Post: 03-11-2009, 11:53 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
  •