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

Thread: How to Make a Script

  1. #1
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How to Make a Script

    ~~~How to Make a Script~~~


    Table of Contents
    1. - The basic setup
    2. - Including SRL
    3. - A procedure's setup
    4. - Your first basic script
    5. - Including other files from the SRL folder
    6. - Constants
    7. - A script using a function from the woodcutting.scar file in SRL
    8. - Variables
    9. - A basic progress report
    10. - Scar's setup
    11. - Failsafes
    12. - Basic Walking


    1. - Lets start it off, this is what your scar window is when it loads up:

    SCAR Code:
    program New;
    begin
    end.

    for the first line, you can change the New to whatever you want, it wont matter at all in the script for the second and third line, those are the outline of your "main loop". We will talk about this later.

    2. - To use the SRL includes in your scripts, change this:

    SCAR Code:
    program New;
    begin
    end.
    to this:
    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    begin
      SetupSRL;
    end.

    now it will setup srl when the script is started and will add MANY fore functions to add, i will talk a little more about this later.

    3. - Now, to make a script do soemthing, you will make a procedure and put functions inside the procedure as such:

    SCAR Code:
    Procedure BlahBlah;
    begin
      Writeln('this message will appear in your debug box at the bottom of your scar window');
    end;
    You can name the procedure whatever you want as long as it isnt being uses already for a procedure in the srl folder or in the script your making already. Something VERY important about procedures is that for each begin you type, there must be an end; for it. ALWAYS remmeber this! Inside this procedure, it will simply type out a message into the debug box. More about procedure in the next step.

    4. - Lets start making a script then, here we go....

    SCAR Code:
    program FirstScript;
    {.include SRL/SRL.scar}

    Procedure AnExampleProcedure;
    begin
      SetRun(True);
      Wait(500 + random(500));
      GameTab(4);
      Writeln('Run is now set on and you are in your inventory gametab');
    end;

    begin
      SetupSRL;
      AnExampleProcedure;
    end;

    Ok, lets break this down so you understand:
    First, I named the program FirstScript, since it is an example of a first script.
    Then, I made a new procedure, which in this case, will set your run on, click on your inventory gametab, then type out a message in the debug box. SetRun and GameTab are both pre-made fucntions inside the srl folder. SRL helps a load when making scripts because it simplifies your procedures. To find out what procedures are there, go to (most likely) C:\Program Files\SCAR 3.06\includes\SRL\SRL\core. Then in the main loop (the begin and end. at the end of the script), I setup srl and did the procedure. Your script must end with an "end." with a period and all other ends in the script should just end with a semicolon ;.

    So now you know how to set up a script, put a procedure in it, how to add srl, and make it work. Next, I will go into a little bit more detail.

    5. - So, what if you want to use procedures and stuff in the C:\Program Files\SCAR 3.06\includes\SRL\SRL\skill folder? Simple do this:

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    {.include SRL/SRL/skill/Woodcutting.scar}
    begin
      SetupSRL;
    end.

    Now you can use procedures and functions from C:\Program Files\SCAR

    3.06\includes\SRL\SRL\skill\Woodcutting.scar

    6. - What Scar is mostly made for i believe is finding colors on the screen. If you want, you can make something called a Constant by doing this:

    SCAR Code:
    program FirstScript;
    {.include SRL/SRL.scar}

    const
      TheTreeColor = 4153432;
      TheMessage = 'Message blah blah';

    Procedure AnExampleProcedure;
    begin
      FindColor(x,y,TheTreeColor,MSX1,MSY1,MSX2,MSY2)
      Writeln(TheMessage);
    end;

    begin
      SetupSRL;
      AnExampleProcedure;
    end;

    A constant can be named anything you want. If a const equals a word, make sure you add ' ' and also make sure all constants ends with a ; A constant makes changing colors and words MUCH easier since they are at the top of the script, so i suggest you use them to your advantage, but you don't need to.

    7. - So lets make a basic script now that uses this SRL woodcutting include....

    SCAR Code:
    program FirstScript;
    {.include SRL/SRL.scar}
    {.include SRL/SRL/skill/Woodcutting.scar}

    const
      NormalTreeColor = 4153432;

    Procedure ChoppingDownTheTree;
    begin
      repeat
        FindColor(x,y,NormalTreeColor,MSX1,MSY1,MSX2,MSY2)
        Mouse(x, y, 1, 1, True);
        Wait(5000 + random(2000));
      until(invcount = 5)
      Writeln('You have 5 items in your inventory now, dropping the logs');
      DropAllLogs;
    end;

    begin
      SetupSRL;  
      repeat
        ChoppingDownTheTree;
      until(false);
    end;

    In this script, I repeat the find a color, move the mouse to it and left click, and wait until the inventorycount is 5. For the findcolor function, it will look for the color on the mainscreen (the MSX1 and stuff are pre-set numbers in srl for the size of the main screen, so if you wanted, you could do MMX1,MMy1,MMx2,MMY2 for the minimap, MCX1 and stuff for the main chat, and so on). Looking through the SRL folder will help a lot in finding new functions to use and also looking through other peoples scripts will show many cool functions in srl used. Everything inbetween the repeat and until will be repeat and once whatever you tell the until to be, it will break out of that loop and do whatever is next. In this case, once there are 5 items in your inventory, it will type a message in the debug box and drop all the logs, which is a function in the srl woodcutting script and i needed to include that at the top so i could use it. Also, in the main loop at the bottom, i added a repeat and an until(false);" this means it will repeat eveyrthing inbetween the repeat and the until forever.

    8. - Ok, a variables is a word/letter that can be ANY value. Here are what the different things they can be, ill tell you more about them later:

    Boolean - True or False
    Integer - Whole Numbers
    String - Words/letters
    Extended - Decimal Numbers

    Ok, so here is an example of a script using variables:

    SCAR Code:
    program UsingVariables;
    {.include SRL/SRL.scar}

    var
      AttemptsTried : Integer;
      IsTheColorFound : Boolean;

    const
      TheTreeColor = 4153432;

    Procedure ClickingATree
    begin
      if(FindColor(x,y,TheTreeColor,MSX1,MSY1,MSX2,MSY2))then
      begin
        Mouse(x, y, 1, 1, True);
        AttemptsTried := AttemptsTried + 1; //adds 1 to the Attempts value
        IsTheColorFound := True; //will be true of the color is found
        Wait(100);
        FFlag(5);
      end else
      begin
        Writeln('Color not found');
        IsTheColorFound := False;
      end;
    end;

    Procedure DidItFindTheColor;
    begin
      if(IsTheColorFound = True)then
      begin
        Writeln('Yay, the color was found');
      end else
      if(IsTheColorFound = False)then
      begin
        Writeln('Aww, the color wasnt found this time');
      end;
    end;

    begin
      SetupSRL;
      repeat
        ClickingATree;
        DidItFindTheColor;
      until(false);
    end.

    So as you can see, I used a boolean value for the IsTheColorFound variable since it resulted in True or False, and for the AttemptsTried variable, it resulted in whole numbers so it is an Integer value. Variables are also used in progress reports a lot to show you the progress of the script is going.

    9. - Ok, every script should have a progress report to show how long and well it has been working, and they are very easy to use. Here is an example of a basic progress report:

    SCAR Code:
    Procedure ProgressReport;
    begin
      ClearDebug;
      Writeln('//---------- Title Of Script ----------\\');
      Writeln('|   Ran for '+TimeRunning);
      Writeln('|   Attempted '+IntToStr(AttemptsTried )+' Times');
      Writeln('\\-----------------------------------//');
    end;

    Progress reports should look neat, tidy, and organized. They show how long the script has been running by using the TimeRunning fucntion from srl, and in this example, AttemptsTried is a variable that your script has been adding up, and using the IntToStr will allow it to be typed (more about this in the Globals.scar file in the srl core folder, and the IntToStr is used ot make the Integer(Int) value to become a String(Str) value so it can be typed as a word). Also, the ClearDebug fucntion will clear the debug box so your debug box wont get too crowded.

    10. - Now you see how to use functions from SRL, how to make a basic script, now ill go into how Scar works.

    To start, you might want to memorize these key bindings for scar(hold all 3 buttosn down at once):
    Play is Ctrl + Alt + R (to play the script)
    Pause is Ctrl + Alt + A (to pause the script so you can start from where you left off(not when the script is closed)
    Stop is Ctrl + Alt + S (to stop whatever script you are running completely)
    Pick Color is Ctrl + Alt + P (to get the color and coords of wherever you click)

    To find a color on the screen such as a rock color, a tree color, ect, just hold down Ctrl + Alt + P all at once. The screen will freeze and then you can click somewhere to get the color. The screen will unfreeze once you click. The color and coords will appear in your debug box such as:
    SCAR Code:
    Color Picked: 6141021 at (575, 176)
    The coords where i clicked (also knows as x,y) are 575,176 in this example and the color i clicked was 6141021.

    To get coords, first drag the crosshair icon on scar onto the runescape client. Otherwise you will be getting the coords on your computer instead of on the runescape client.

    11. - Now then, to make good scripts, you will want failsafes and backup plans if the first thing doesnt work. Lets look at this procedure:

    SCAR Code:
    Procedure UsingAFailsafe;
    begin
      if(FindColor(x,y,4153432,MSX1,MSY1,MSX2,MSY2))then
      begin
        Mouse(x, y, 1, 1, True)
      end else
      begin
        Writeln('The color was not found, terminating script');
        TerminateScript;
      end;
    end;

    For this example, if it finds the color on the main screen, it will click it, but if its not found, then it will type a message in the debug box and terminate the script. In scripting, you will NEVER EVER EVER want something that can repeat forever, always put in backup options if the first thing doesnt work!

    12. - So now you have the basic foundation on how to make a script, lets move on even more into more advanced stuff such as walking

    The best way to walk in SRL is probably symbols, clicking, and DTM's. I will go into DTM's later, but for now, ill show you how to find symbols and how to walk by clicking. Here is a simple procedure on how to find the water source symbol:

    SCAR Code:
    Procedure FindingTheWaterSymbol;
    begin
      if(FindSymbol('water'))then
      begin
        Mouse(x, y, 2, 2, True);
        Wait(1000);
        FFlag(5);
      end else
      begin
        Writeln('The symbol was not found, using backup click')
        Mouse(626, 39, 2, 2, True);
        Wait(1000);
        FFlag(5);
      end;
    end;

    So in this example, if it finds the water symbol, it will click it, wait 1 second, then wait until the flag on the minimap is gone (more about functions such as FFLag and stuff in your SRL folder). If it doesn't find the symbol though, it will do a "blind click" since its just clicking in the general direction of where the symbol usually is(about how to find coords was stated above).

    To find out all the valid symbols to look for, look here: C:\Program Files\SCAR 3.06\includes\SRL\SRL\core\symbols.scar

    More To Come~~~~~~~~~~~~~~

    Best way to learn i think is looking through the SRL folder and looking through other peoples scripts.

    *I have one golden rule I would like everyone to follow while scripting though:
    NEVER use anything you dont know, never copy a procedure from another script, always only use what you know. Many people will just copy stuff from other scripts and start ranting about how they cant get something to work since they dont know how it works. You might think "if it works in this script, why wouldn't it work in mine", it is best and safest to make everything by yourself and if you get stuck, you can look in other scripts, but dont just copy and paste from other scripts a lot.

    Coming later:
    - More detail about functions, procedures, and features of SRL/Scar
    - case of statements
    - Multi-players
    - A little more about the basics of how to walk
    - RadialWalk
    - Finding Bitmaps
    - Finding DTM's

    if you have any questions, feel free to message me on msn or aim.

    If there is anythign that should be added, please say so and I will.

  2. #2
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I just typed this up in a couple minutes so it has errors and stuff, I was bored lol. Much more to come when I have the time.

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

    Default

    Nice tut For Begginers, very good explantions.


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

  4. #4
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ty, i still have a lot mroe to add and improve, but i think this is a good start for like less than 30 min of work lol.

  5. #5
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

  6. #6
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bobbohobbo View Post
    Nice guide.
    Cool, glad you liked it.

  7. #7
    Join Date
    May 2007
    Location
    Ohio, USA
    Posts
    96
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks, this is helping me a lot with my first script, a Yew Cutter.

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

    Default

    Even though there are over 5000 different tuts explaining this stuff/the upcoming stuff already, it's still a pretty good tut

    7. - A scritp using a function from the woodcutting.scar file in SRL

    Fix it!

  9. #9
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by JAD View Post
    Even though there are over 5000 different tuts explaining this stuff/the upcoming stuff already, it's still a pretty good tut

    7. - A scritp using a function from the woodcutting.scar file in SRL

    Fix it!
    I didn't eve nbother to read the other tuts that were out there, I didn;t notice lol.

    And im sorry, it was typed up fast and i made a spelling error, PLEASE forgive me all mighty JAD

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

    Default

    Quote Originally Posted by Rune Hacker View Post
    I didn't eve nbother to read the other tuts that were out there, I didn;t notice lol.

    And im sorry, it was typed up fast and i made a spelling error, PLEASE forgive me all mighty JAD
    Lol Just thought I'd tell you so people don't go into an uncontrollable rage like I did when I saw that spelling error lol

  11. #11
    Join Date
    Jan 2007
    Location
    Palestine
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    In number 8 when compiling it says ...

    Failed when compiling
    Line 5: [Error] (17672:1): Duplicate identifier 'Attempts' in script

    whats the problem ?? i treid mine and it didnt work .. i pasted your it said the same thing also .. plz help or fix the problem .. ?

  12. #12
    Join Date
    Jun 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    it means you have a procedure or similar with the same name as an actual word used in the "code" (for want of a better word), i think that if you change the name of the variable Attempts to something else, and make sure you then change this in the ClickingATree procedure. I think this should work can someone with more experience with me confirm?

    Edited for i am teh noobzor.

  13. #13
    Join Date
    Aug 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    tyvm guide really helped me to make automine

  14. #14
    Join Date
    Aug 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Good tutorial! Lots of help!

  15. #15
    Join Date
    Jun 2007
    Location
    NSW, Australia.
    Posts
    541
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice addition Rune Hacker.

    This covers pretty much everything, sure, it could be a little better in some parts, as you said... but I'm not critisizing at all.

    I was going to make something like this, but this sums it up quite nicely.
    Quote Originally Posted by RAM View Post
    I sam sofa king wee todd did ! ~RAM
    My SRL Army Blog.


  16. #16
    Join Date
    Aug 2007
    Posts
    282
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Very understandable, good tut

    could have used it before i learned... thats ok, it will help others!

  17. #17
    Join Date
    Sep 2007
    Location
    manchester, england
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hi great tut ive just started a script would i be able to like change stuff so it would mine ore and drop it insted of wood eg

    Code:
    program new;
    {.include SRL/SRL.scar}
    {.include SRL/SRL/skill/mining.scar}
    
    const
      normalorecolor = 7303288
    
    Procedure mingingtheore
    begin
      repeat
        FindColor(x,y,Normalorecolor,MSX1,MSY1,MSX2,MSY2)
        Mouse(x, y, 1, 1, True);
        Wait(5000 + random(2000));
      until(invcount = 5)
      Writeln('You have 5 items in your inventory now, dropping the ore');
      DropAllOre;
    end.
    
    begin
      SetupSRL;
      repeat
        mineore;
      until(false);
    end;
    somthin a bit like that

  18. #18
    Join Date
    Sep 2007
    Location
    In A Box
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    nice thread im trying to make my own one now =]

  19. #19
    Join Date
    Aug 2007
    Location
    Washington
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Man I still feel lost lol, I'm getting there I've read a lot of tutorials and flipped through the Pascal computer language
    now all I have to do is make myself a script!

  20. #20
    Join Date
    Sep 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i am new so i still odn't rely know what to do

  21. #21
    Join Date
    Sep 2007
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Rune Hacker View Post
    Ty, i still have a lot mroe to add and improve, but i think this is a good start for like less than 30 min of work lol.
    Ha! All that in 30 minutes? Impressively thorough.

  22. #22
    Join Date
    Jan 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great tutorial. I thought the walking part very helpful.

  23. #23
    Join Date
    Dec 2007
    Location
    Behind you >:O
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    pretty good tut! keep up the good work

  24. #24
    Join Date
    Jan 2008
    Location
    Muskegon MI
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thank you so much for the help. im getting started right now!

  25. #25
    Join Date
    Feb 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    I need an autominer

    Quote Originally Posted by bigbadboy2 View Post
    tyvm guide really helped me to make automine
    so does ur script work? if so can u post it on here? or email it to me? i'd greatly appreciate it seeing as how all the premade ones on google never work, and i dont get how to make them based off of these tutorials.

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. how should i make this script
    By bloodydemon in forum OSR Help
    Replies: 16
    Last Post: 10-21-2008, 03:09 AM
  2. First Script What should i make??
    By kornthebldgd in forum First Scripts
    Replies: 36
    Last Post: 08-14-2008, 07:13 PM
  3. Need Someone To Make Script With
    By skilld u in forum RS3 Outdated / Broken Scripts
    Replies: 0
    Last Post: 10-06-2007, 10:21 PM
  4. Can someone make a script that.
    By Camaro' in forum RS3 Outdated / Broken Scripts
    Replies: 4
    Last Post: 06-11-2007, 08:24 PM

Posting Permissions

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