PDA

View Full Version : Creating your first Scar Script



TravisV10
08-29-2007, 09:03 PM
[B2C][TUT]Creating your first Scar Script by Travis

In this tutorial, you will learn the basics of scripting with Scar and you will make your first script!


Lets get started!

Part 1-


Background/History:

Scar was created by Freddy1990 @ Freddy1990.com. Scar is Pascal, a programing language, but is called Scar Scripting because it used SRL and functions that plain Pascal doesn't have. SRL is Pascal functions altered so that you can script "easier" and more efficient. It is here so that everyone's functions and procedures can be pulled together, such as randoms.



Step 1:

Open up Scar. (Be sure to have the latest version of Scar and SRL)

http://img338.imageshack.us/img338/5906/88831133hv6.png

Read the text in the image above ^^^


Step 2:

When you start up Scar, you should see this:

program New;
begin
end.


program New; - NEW is the name of your script. You must have program New; at the beginning of every script to tell Scar when the script starts.

begin - Tells Scar what functions and procedures to read.

end. - Tells Scar the script is now over.


For some of you, this may be over your head. Relax, you will understand at the end of this tutorial.



Step 3 - Starting your first script:

This is your first scripting exercise.

Copy and paste this code into Scar:

program HelloWorld;

procedure HelloWorldLn;
begin
WriteLn('Hello World!');
end;

begin
HelloWorldLn;
end.

Then click the play button and you should see this:

http://img258.imageshack.us/img258/9716/77160940ta9.png (http://imageshack.us)


Step 4:

procedure HelloWorldLn;
begin
WriteLn('Hello World!');
end;

procedure HelloWorldLn; - This is the name of your procedure.

begin - This tells Scar that the procedure is about to begin.

WriteLn('TEXT HERE'); - WriteLn is used to write a message in the debug menu. Every function/procedure within a procedure needs to have a semicolon at the end. (";")

end; - This tells Scar that the procedure has ended.

begin
HelloWorldLn;
end.

HelloWorldLn; - This tells Scar to call upon the procedure HelloWorldLn. Once again, this ends in a semicolon.


And that is all that is to it! You know have made your first script!
Are you ready for part 2?

Part 2-

Comments in Scar are a must. First of all, it helps you out when you are scripting and can help others out when reviewing your script.

There are several types of comments. The post popular ones are:


{
*Comments here
}

^^^ This uses multi-lines and starts with "{" and ends with "}".

and...

//*Comments here

^^^This is a single line comment. Starts with "//" and ends with whatever

You will know if you have correctly posted a comment if, in Scar, the text shows up green.


And there you have it! You know can tell all of your friends, "Hey, I can script Scar!".

Have fun and I hope you enjoyed my Tutorial!

~Travis

Dan Cardin
08-29-2007, 09:07 PM
nice tut for complete beginners but i would add a second part where u get into simple powerminers and things(though then u'd need to teach like loops and dtms and maybe cases so that might not be the way u were going)

oh riiight first script...for some reason i thought it said learn to script or something like that:p (still its a very easy first script)

and yes im very very fast ;)

TravisV10
08-29-2007, 09:14 PM
nice tut for complete beginners but i would add a second part where u get into simple powerminers and things(though then u'd need to teach like loops and dtms and maybe cases so that might not be the way u were going)


This is just for your first script, not a power miner. Thank you for posting Dan! (also, you got first post! That's fast!)

~Travis

Santa_Clause
08-29-2007, 10:09 PM
Ooo...not a bad tutorial.

TravisV10
08-30-2007, 12:08 AM
Ooo...not a bad tutorial.

Thank you very much Santa. I worked hard on it! XD

~Travis

I B X R
08-31-2007, 04:12 AM
Meh, it was alright, good effort though. I couldn't have made this, but I already knew the material...

+ rep :p

TravisV10
08-31-2007, 10:45 AM
Meh, it was alright, good effort though. I couldn't have made this, but I already knew the material...

+ rep :p

Thanks!

~Travis

the fuh-king
09-04-2007, 07:04 PM
Thank you very much Santa. I worked hard on it! XD

~Travis

im a compleat scar/slr noob so this was great i played around with it adding diffrent functions and now im working on....you guessed it a power miner.

ill post it if you guys would kindly test it for me, wont be good but eh whatever lol.

+rep

Gama-Bomb
09-04-2007, 11:11 PM
Thanks for that, helped me quite a bit