[TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

Discussion in 'Scar/Simba Help' started by WhoCares357, Mar 25, 2007.

[TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)
  1. Unread #1 - Mar 25, 2007 at 5:09 PM
  2. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Unmatched Beginner's Guide to Scripting Scar (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.srl-forums.com/forum/tut-unmatched-beginners-t5444.html.

    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.srl-forums.com/forum/tut-unmatched-beginners-t5444.html. 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:

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

    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)

    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)

    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)

    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)

    [​IMG]

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

    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, that 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.

    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 code, 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.

    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 code see i as 1 (i:= 1;). Then, I told ScarS 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.

    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.

    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.

    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.

    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.

    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.

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

    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.

    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.

    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.

    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.

    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.

    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.

    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.

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

    Code:
    program Includes;
    
    {.include AutoMiner.code} //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.code}).

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

    Code:
    program Includes;
    
    {.include SRL\SRL.scar}
    
    begin
    //Use procedures from SRL script
    end.
    The reason the include has two parts to it (SRL\SRL.scar) is because the file SRL is located in a file called SRL.scar 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.
     
  3. Unread #2 - Mar 25, 2007 at 5:17 PM
  4. Town
    Joined:
    Jan 21, 2007
    Posts:
    3,776
    Referrals:
    3
    Sythe Gold:
    5

    Town Grand Master
    Scar Programmers

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    :JawDrop:

    Nice.
     
  5. Unread #3 - Mar 25, 2007 at 5:22 PM
  6. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    What can I say. I'm a strong believer. ;)
     
  7. Unread #4 - Mar 25, 2007 at 5:28 PM
  8. WoW Sucks
    Joined:
    Jan 21, 2007
    Posts:
    3,708
    Referrals:
    3
    Sythe Gold:
    0

    WoW Sucks Global Moderator
    Banned

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Amazing once again ;)

    On your other guide, it had a list of chapters, it would be nice if you did that again ;)

    But its up to you.
     
  9. Unread #5 - Mar 25, 2007 at 5:29 PM
  10. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Will do master WoW! (Thanks for pointing out.)
     
  11. Unread #6 - Mar 25, 2007 at 5:39 PM
  12. WoW Sucks
    Joined:
    Jan 21, 2007
    Posts:
    3,708
    Referrals:
    3
    Sythe Gold:
    0

    WoW Sucks Global Moderator
    Banned

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Anytime ;)
     
  13. Unread #7 - Mar 25, 2007 at 5:42 PM
  14. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Oh yeah. If anyone finds an error (grammar, script, or other) please tell so I can fix it.
     
  15. Unread #8 - Mar 25, 2007 at 7:21 PM
  16. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Wow, looks like you worked hard to write this. Seems useful. Stickied.
     
  17. Unread #9 - Mar 25, 2007 at 7:23 PM
  18. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Thanks SMR. Glad to be of service.
     
  19. Unread #10 - Mar 27, 2007 at 7:01 PM
  20. iwaschosen
    Referrals:
    0

    iwaschosen Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    amazing, the procedures part taught me alot! now my script will be somewhat organized! thanks alot, its a great refrence tool!

    oh and i also learned how to send the enter key thanx to this (chr(13)) :p
    thanx again
     
  21. Unread #11 - Mar 28, 2007 at 1:13 PM
  22. Grimskraper
    Referrals:
    0

    Grimskraper Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    ok I have a quick question. As I am trying to learn to script a Runescape auto miner, is there any way I can make a character be held down? I'm not sure as to what the arrow keys are, but is there a command that holds down one of those characters so in runescape it could move the arrow keys if it doesn't find a certain color within a certain coordinates? (also a reference to where I can find all the characters would help me and other people out a lot I bet:))

    Also great work on this, I feel I learned a lot more, not that I knew much already anyways.
     
  23. Unread #12 - Mar 28, 2007 at 4:51 PM
  24. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    SendArrowSilent(0); - Sends arrow to Client's window. For 0 = up, 1 = right, 2 = down, 3 = left.

    I'm not sure about pressing a certain key other than those.
     
  25. Unread #13 - Mar 30, 2007 at 6:38 AM
  26. assboy
    Referrals:
    0

    assboy Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    i need help i read the guid then i made a script , not finished i just wanted to test the first few seconds and i get asn error wen i run. you start in varrock bank (east)
    [Error] (29:4): Identifier expected
    anyway here is the script

    program randomwoodctter;

    var
    x,y: integer;

    const
    bankcolour= 3127755;
    rockcolors= 2303520;
    treemapcolors= 18449;

    begin
    if(findcolor(x,y,rockcolors,582,11,758,157)) then
    begin
    movemousesmoothex(x,y +random(0),20,40,45,25,20);
    wait(1000+random(500));
    clickmouse (x,y,true);

    begin
    if(findcolor(x,y,treemapcolors,582,11,758,157)) then
    begin
    movemousesmoothex(x,y +random(0),20,40,45,25,20);
    wait(1000+random(500));
    clickmouse (x,y,true);
    end else
    writeln('did not find rockcolor');
    end.
     
  27. Unread #14 - Mar 30, 2007 at 6:40 AM
  28. assboy
    Referrals:
    0

    assboy Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    i need help i read the guid then i made a script , not finished i just wanted to test the first few seconds and i get asn error wen i run. you start in varrock bank (east)
    [Error] (29:4): Identifier expected
    anyway here is the script

    here on starts

    program randomwoodctter;

    var
    x,y: integer;

    const
    bankcolour= 3127755;
    rockcolors= 2303520;
    treemapcolors= 18449;

    begin
    if(findcolor(x,y,rockcolors,582,11,758,157)) then
    begin
    movemousesmoothex(x,y +random(0),20,40,45,25,20);
    wait(1000+random(500));
    clickmouse (x,y,true);

    begin
    if(findcolor(x,y,treemapcolors,582,11,758,157)) then
    begin
    movemousesmoothex(x,y +random(0),20,40,45,25,20);
    wait(1000+random(500));
    clickmouse (x,y,true);
    end else
    writeln('did not find rockcolor');
    end.
     
  29. Unread #15 - Mar 30, 2007 at 4:28 PM
  30. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    You forgot a few ends. For every begin, there must be an end.

    Code:
    program randomwoodctter;
    
    var
    x,y: integer;
    
    const
    bankcolour= 3127755;
    rockcolors= 2303520;
    treemapcolors= 18449;
    
    begin
    if(findcolor(x,y,rockcolors,582,11,758,157)) then
    begin
    movemousesmoothex(x,y +random(0),20,40,45,25,20);
    wait(1000+random(500));
    clickmouse (x,y,true);
    begin
    if(findcolor(x,y,treemapcolors,582,11,758,157)) then
    begin
    movemousesmoothex(x,y +random(0),20,40,45,25,20);
    wait(1000+random(500));
    clickmouse (x,y,true);
    end else
    writeln('did not find rockcolor');
    end;
    end;
    end.
     
  31. Unread #16 - Mar 30, 2007 at 7:41 PM
  32. Grimskraper
    Referrals:
    0

    Grimskraper Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Thanks WhoCares for telling me the command for pressing down arrow keys, but if it sends that key, how long can it make the camera turn? would something like this make it turn enough?
    Begin
    Repeat
    SendArrowSilent(0);
    UntillFindColor(x,y,######,#,#,#,#)
    end;
    The #s being just any random number I might use in that situation.
    Could I insert that into a script in the part I wanted it to mine rocks in?
    And my time away from the computer is dulling my memory a little so I'm readin your guide over and over again :p (well atleast parts). So if I post somethin that you anyone sees is wrong help me out a little.
    -Thanks
     
  33. Unread #17 - Mar 30, 2007 at 10:18 PM
  34. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Yes, but there is something else you could use:

    Code:
    procedure SendArrowSilentWait(a: Byte; WaitTime: Integer) - Sends an arrow to Client's window like SendArrowSilent and holds it for a given wait time.
    Example: SendArrowSilentWait(1, 10); //holds "Right" arrow for 10 milliseconds.
     
  35. Unread #18 - Mar 31, 2007 at 4:58 PM
  36. Grimskraper
    Referrals:
    0

    Grimskraper Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Ah that was something that I was looking for, but the real question, which would be better if I didn't want to get caught by Jagex's Ant-bot Software:cool:. Also, When I test what I have so far, I get an error that reads :[Error] (17666:1): Duplicate identifier 'x' in script. It then moves my crusor to the x where I have x, y: Integer;.

    My Yahoo! name is GrimSkraper (Ironic eh?) and I can talk to people on MSN through yahoo, or if you want, I have a MSN account as well, its [email protected] but I am rarely on. I'll get that in my profile soon.
    Again, thanks.
     
  37. Unread #19 - Mar 31, 2007 at 9:45 PM
  38. WhoCares357
    Joined:
    Jan 21, 2007
    Posts:
    608
    Referrals:
    1
    Sythe Gold:
    0

    WhoCares357 Forum Addict

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Are you using SRL? SRL has its own x and y. You can use x and y without Identifying them, or you can just make like x1, y1.
     
  39. Unread #20 - Apr 1, 2007 at 5:48 PM
  40. Grimskraper
    Referrals:
    0

    Grimskraper Guest

    [TUT]Unmatched Beginner's Guide To Scripting Scar (Hands On)

    Yes I am using SRL, which took me 5 hours to set up, and I don't know why but after I restarted my computer it started working. So basicly I don't have to put in
    x,y: integer;
    ?
    Alrighty then that makes me one happy person, but I'll probably go down in in history as the only person to be stuck for weeks on his script tryin to identify x and y >.< Ok I think I'll just post what I have so far in one of the other forums cause I'm still getin errors I'm not sure of.
     
< listing mcas movie theater | Need scar Tin miner. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site