Newbie Guide For SCAR - Bebemycat2

Discussion in 'Code Snippets and Tutorials' started by Anonymous, Dec 16, 2006.

  1. Anonymous

    Anonymous Guest

    Newbie Guide For SCAR

    CREATED BY Bebemycat2

    Attention SCAR newbies: Before you start scripting, you should read this


    What is this going to cover?

    This tutorial will take you step by step through the process of learning how to create your very first script. I will explain every step to you and also throw in some useful scripting tips along the way.


    Tutorial:

    Ok to begin I will ask you to open up SCAR. Now all you should see is this:


    Code (Text):
    1. program New;
    2. begin
    3. end.
    Well I want you to space all of those out a bit like this:

    Code (Text):
    1. program New;
    2.  
    3.  
    4.  
    5. begin
    6.  
    7.  
    8. end.
    This will give us some space to code in. This is just the basic elements. program New; This is your programs name, Change "New" to whatever name you want your program to be. Always add a semicolon ( ; ) after the name to tell the script that that is the end of your scripts name. begin Tells the compiler that the script has just began, the coding of your script goes between "begin" and "end." end. Tells the compiler that you have ended the script, Make sure to always put a full stop. If you are making a procedure/function then you end it with a semicolon ( ; ), that will be explained later in the tutorial.

    Next thing we are going to do is this:


    Code (Text):
    1. program script;
    2.  
    3.  
    4.  
    5. procedure;
    6. begin
    7.  
    8.  
    9.  
    10.  
    11. end.
    You will notice that I have added something called a Procedure. Well a "procedure" is basically this:

    This procedure is where we will create the "body" or the majority of our script, from there is can be called upon later in the "main line" this I will explain more about later.

    You also have to have a name for your procedure, so lets name it "Hello" and add a semi-colon after it so it looks like this:

    Code (Text):
    1. program script;
    2.  
    3.  
    4.  
    5. procedure;
    6. begin
    7.  
    8.  
    9.  
    10.  
    11. end.
    You name the procedure so that you can "call" upon it later in the script. You can name it anything but I am going to use "Hello" for this script.

    Now what we are going to do now is add somthing called a "const" or a constant. This means that this "setting" will stay the same throughout the entire script.

    To make a const you simply need to do this with your script:


    Code (Text):
    1. program script;
    2.  
    3. const
    4.  
    5. procedure hello;
    6. begin
    7.  
    8.  
    9.  
    10.  
    11. end.
    Now we have to make something a const, so let make it this:


    Code (Text):
    1. program script;
    2.  
    3. const
    4. Message1='Hello world!';
    5.  
    6. procedure hello;
    7. begin
    8.  
    9.  
    10.  
    11.  
    12. end.
    Now you will notice that I have "Message1=" this is because with SCAR you have to always tell it what the "Message1" equals, that's the reason for the "=". Now for the ' ' marks. These are what SCAR uses to identify when a String begins and when it ends. A string is a word / phrase. You will notice that it has a pinkish color to it, that is the "Syntax highlighting" that SCAR creates so that scripting can be much simpler.

    Now that we have a "const" we need it to do something. You can find a basic list of procedures and functions in your SCAR folder called "procedureparams". It should look somthing like this:


    Code (Text):
    1. procedure Writeln(s: string);export;
    2. procedure Status(s: string);
    3. function GetStatus: string;
    4. function Readln(question: string): string;
    5. function GetChatMsg: string;
    6. function GetLastChatMsg: string;
    7. ......
    8. ......
    and so on. Now scroll down the list until you come to a procedure called:


    Code (Text):
    1. Writeln(s: string);
    Now as I explained before a procedure is:

    This procedure:


    Code (Text):
    1. procedure Writeln(s: string);
    just means that the "S" is a string, so therefore that is where we would enter what we wanted to type.

    So I want you to make your Script look like this now:


    Code (Text):
    1. program script;
    2.  
    3. const
    4. Message1='Hello world!';
    5.  
    6. procedure hello;
    7. begin
    8. Writeln();
    9.  
    10.  
    11.  
    12.  
    13. End.
    You will notice that I have "Writeln();" after the begin, that is because you have to begin the script before you can do anything.

    Also "Writeln" is a typing "command", it tells SCAR to type the keys that you specify. The Text will show up in shomthing called the "Debug" box that is this area of SCAR:
    [​IMG]


    Now we will do this:

    Code (Text):
    1. program script;
    2.  
    3. const
    4. Message1='Hello world!';
    5.  
    6. procedure hello;
    7. begin
    8. Writeln(Message1);
    9.  
    10.  
    11.  
    12.  
    13. End.
    Now normally we would have to use the ' ' identifiers around "Message1" but in this case, since it is already in the "const" there is no need to and this will tell SCAR to type what you have filled out in the "const" "Message1".

    Now we have to tell SCAR that we want to end the current procedure for this we will add "end;" like so:

    Code (Text):
    1. program script;
    2.  
    3. const
    4. Message1='Hello world!';
    5.  
    6. procedure hello;
    7. begin
    8. Writeln(Message1);
    9. end;
    10.  
    11.  
    12.  
    13.  
    14. end.
    This is simply to tell SCAR to end the procedure, you will do the same with a function.
    "End;" is different from "end." because "end." tells SCAR to end the whole script while "end;" tells it that you are done with a procedure/function.

    Now we have to make SCAR actually type our "message" and use our procedure that we have just created. to do this we have to create the "main line" I mentioned before. This is done much like a procedure but has a few differences that I will explain.

    So to start off your "main line" you will need to have a "begin" like so:


    Code (Text):
    1.  
    2. program script;
    3.  
    4. const
    5. Message1='Hello world!';
    6.  
    7. procedure hello;
    8. begin
    9. Writeln(Message1);
    10. end;
    11.  
    12.  
    13. begin
    14.  
    15. end.
    You will notice the begin is there, this is just telling SCAR this is where your main line shall begin. Simple, no?

    So now we are going to make SCAR repeat something. The command to make SCAR repeat is "repeat". This will go after the being in the "main line". So you should now have code that looks like this:


    Code (Text):
    1.  
    2. program script;
    3.  
    4. const
    5. Message1='Hello world!';
    6.  
    7. procedure Hello;
    8. begin
    9. Writeln(Message1);
    10. end;
    11.  
    12.  
    13. begin
    14. repeat
    15.  
    16. end.
    This basically telling SCAR to begin the "main line" and repeat something. Now we have to tell it what it needs to repeat. For this we will take our procedures name (Hello) and add it under our repeat command. So it should look like this:

    Code (Text):
    1. program script;
    2.  
    3. const
    4. Message1='Hello world!';
    5.  
    6. procedure Hello;
    7. begin
    8. Writeln(Message1);
    9. end;
    10.  
    11.  
    12. begin
    13. repeat
    14. hello;
    15.  
    16. end.
    This will tell SCAR to repeat our "Hello procedure". But we have to tell it how long it has to repeat it for, so we will need the command "until". like so:

    Code (Text):
    1.  
    2. program script;
    3.  
    4. const
    5. Message1='Hello world!';
    6.  
    7. procedure Hello;
    8. begin
    9. Writeln(Message1);
    10. end;
    11.  
    12.  
    13. begin
    14. repeat
    15. hello;
    16. until(false)
    17. end.
    Now you will notice that I have "until(false)" when I only told you to add "until". Well until needs some sort of "time marker" to tell it when to repeat until, and "(false)" tells it to repeat forever, this will make it an infinite "loop". With "until(false)" this script will repeat our procedure "Hello" forever, never stopping until the user stop SCAR manually.

    Now hit: "script" -----> "Compile" and you should get this message in the "debug" box that says "Successfully compiled" this means that you coded the script right. Now to test it.

    With your "crosshair"([​IMG]) select your debug box and hit "run script". You will notice that it keeps typing it over and over really fast. So now we need to slow it down a bit. for this we will use a procedure called "wait". Wait tells the script to wait a designated amount of miliseconds before it's next action. To add wait what we do is this:

    Code (Text):
    1.  
    2. program script;
    3.  
    4. const
    5. Message1='Hello world!';
    6.  
    7. procedure Hello;
    8. begin
    9.   wait(1000)
    10.   Writeln(Message1);
    11. end;
    12.  
    13.  
    14. begin
    15.  repeat
    16.    hello;
    17.  until(false)
    18. end.
    You will notice the "1000)" this is the amount of milliseconds you want to wait, now if you paid attention in math(s) (Depending on if your American or not you call it math or maths) you will know that 1000 milliseconds is 1 second. So we are basically saying that when SCAR reads the "main line" and does our procedure "Hello" that it should wait 1 second before it repeats. Simple, no?
    Now run it.

    You will see that it types at a much more controlled rate now.



    CONGRATULATIONS! You have just made your very first script!


    CREDIT'S FOR THIS GUIDE GO TO:
    • Deathader
      Bebemycat (different forum, he tought me SCAR)
      Kaitnieks (creating SCAR)
      The people that keep SCAR running

    +rep would be AWESOME

    Note: I stole some of the code form a different site
     
  2. Anonymous

    Anonymous Guest

    Design tips:

    When you want to leave notes to the user of your script like this:


    Code (Text):
    1. program script;
    2.  
    3. const
    4. Message1='Hello world!';
    5.  
    6. procedure Hello;
    7. begin
    8.   wait(1000)
    9.   Writeln(Message1); // this says hello
    10. end;
    11.  
    12. begin
    13.  repeat
    14.   hello;
    15.  until(false)
    16. end.
    Now you will notice that I used "//". This tells SCAR not to include what comes after the "//" in the script.
    Now if you don't feel like using "//" every time you want to comment on something, then you can use " { " and " } ". examples of both.

    with //:

    Code (Text):
    1.  
    2. program script;
    3.  
    4. const
    5. Message1='Hello world!';
    6.  
    7. procedure Hello;
    8. begin
    9.   wait(1000)
    10.   Writeln(Message1); // this says hello wolrd!
    11. end;
    12.  
    13. begin
    14.  repeat
    15.   hello;
    16.  until(false)
    17. end.
    with { and }:

    Code (Text):
    1.  
    2. {
    3.   This a script in scar that will say
    4.    Hello world!
    5. }
    6.  
    7.  
    8. program script;
    9.  
    10. const
    11. Message1='Hello world!';
    12.  
    13. procedure Hello;
    14. begin
    15.   wait(1000)
    16.   Writeln(Message1);  { this says hello}
    17. end;
    18.  
    19.  
    20. begin
    21.  repeat
    22.   hello;
    23.  until(false)
    24. end.
    You will notice that with { and } that you can do multiple lines where as with // you can not with out constantly typing "//" over and over.

    Thanks for reading this guide!
     
  3. Hally

    Hally Level IV

    Joined:
    Nov 16, 2006
    Messages:
    1,184
    Likes Received:
    34
    I'm stickying this.
     
  4. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    this looks a really good guide
    +rep
    EDIT: iwould but i cannot as i have already given you +rep for something else
    btw this is a really annoying feature and i think it should be removed
     
  5. Anonymous

    Anonymous Guest

    Thanks. that should help people notice it, so our SCAR store can grow :)

    i know.. I wish they would remove that. :(
     
  6. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Thanks!!! I really needed a guide for SCAR!!! :D :D :D
     
  7. X Joe Kickass X

    X Joe Kickass X Level IV

    Joined:
    Nov 18, 2006
    Messages:
    1,401
    Likes Received:
    0
    Location:
    Behind You
    Thanks
    i liked it!
     
  8. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    thanks
    i have done your tutorial and know the very basics but don't know how you relate this to neopets games
    it would be great if you could give us an example of how to make a script for a neopets game (preferably the simplist one) as that would help us understand how to do other games as well
    well thanks again and hope you do what i have suggested above
    EDIT: just gave you +rep as i was able too
     
  9. Reconmiester

    Reconmiester Level II

    Joined:
    Dec 27, 2006
    Messages:
    268
    Likes Received:
    0
    You even sure that he can take that idea? I mean... He did not even create this guide... Notice how your suggest has not been answered while he goes online everyday and stays online like all day.

    Dont take this the wrong way, I am not saying he cannot script ( I know he can probably script...)

    I am saying that it is not yours because you did not create it. Atleast give credits to work that is not yours. This can be considered plagiarism. Instead, I see no credits, no name of original creator.

    This guide is created by Bebemycat2 at (Website not saying as it is against the rules).

    Please edit this so called your guide and place the credits that deserve to be there.



    My 2 cents.
     
  10. jakeballa

    jakeballa Level I

    Joined:
    Nov 30, 2006
    Messages:
    48
    Likes Received:
    0
    thanks for the help
     
  11. chaoz_enigma

    chaoz_enigma Level I

    Joined:
    Dec 24, 2006
    Messages:
    133
    Likes Received:
    0
    Location:
    Singapore
    I personally think u are out against him just because he have done something wrong. Cant u give it a rest? Neofriend is a friendly community, I am sure everyone wants and try to forgive and forget. If u bear a grudge about him u would onli cause many unhappiness and i am sure this is not wanted in this community am i right? So move on don't stop here Fogive and Forget.
     
  12. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    this was posted on the day deathader got banned and it was THAT post that got him banned so really that post couldn't have been given a rest
     
  13. lazypando

    lazypando Level IV

    Joined:
    Nov 16, 2006
    Messages:
    3,326
    Likes Received:
    94
    Is SCAR any easier than java? That's what I've been learning.... But thanks for the Guide :D
     
  14. Ryan

    Ryan Level II

    Joined:
    Jan 23, 2007
    Messages:
    251
    Likes Received:
    1
    Looks easier than java, but java is object oriented which is worth a lot.
     
  15. jdp1230

    jdp1230 Level III

    Joined:
    Jun 3, 2007
    Messages:
    397
    Likes Received:
    0
    Location:
    Florida
    THANK YOU
     
  16. jduran1

    jduran1 Level I

    Joined:
    Jun 3, 2007
    Messages:
    53
    Likes Received:
    0
    i think this is a good duide and i seem to understand it however i was hoping that in a NEWBIE guide for this program they would explain how i would get this program. I am extremely new when it comes to dealing with programs and am trying to get a good understanding of it however i beleive that i first need this SCAR thing everyone speaks of and have no idea where to find it. :( Could someone help me out.?
     
  17. jduran1

    jduran1 Level I

    Joined:
    Jun 3, 2007
    Messages:
    53
    Likes Received:
    0
    sorry for the double post, someone just sent me alink to the program, thanks anyway.

    To smellyman: thanx i hadnt noticed the edit button :D
     
  18. Smelly

    Smelly Level IV

    Joined:
    Dec 1, 2006
    Messages:
    2,197
    Likes Received:
    8
    Location:
    England
    Thats where the handy "edit" button at the top right hand corner of the post comes into play. Use it.
     
  19. Phee

    Phee Moderator
    Staff Member

    Joined:
    Aug 18, 2007
    Messages:
    6,206
    Likes Received:
    101
    I'm getting this error message when I'm compiling (obviously)

    Failed when compiling
    Line 8: [Error] (8:1): Unknown identifier 'WriteIn' in script

    I have it typed exactly as in the example.
     
  20. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    it will probably be something else wrong with your script
    if you post it here or pm me it i could debug it for you