PDA

View Full Version : The Basics of Scar!



Bionicle
09-15-2009, 07:49 AM
Hello, and welcome to my third tut, The Basics of Scar for Complete Nooblets!

Layout of SCAR Divi CDE

http://freddy1990.com/images/screenshots/scar.png

Ok, so there are three main sections to this layout. The largest box with the program New; in it is where you write your script. The longer box on the bottom is called the 'DeBug Box'. This is where the progress of your script is put while it's playing. It's also where news is downloaded when you start scar. The third box is on the right side. This is your 'Function List'. This is where all your functions and procedures (will be explained later on) go. The crosshair, which looks somewhat like this:

http://www.freeclipartnow.com/d/41645-1/Crosshairs.jpg

(Sorry but i couldn't find an exact image) you drag this over the client, e.g. the runescape window if your using a runescape script, and the script will run within that space.

The play, pause and stop buttons control the script. Hotkeys for these are Ctrl + Alt + R to play, Ctrl + Alt + P to pause and Ctrl + Alt + S to stop.

This is all you really need to know for now ;)

program New;

Lets open up scar, you should see this:
program New;
begin
end.
First I'll explain the first line.
'program New;' is the name of your program. You should call it something related to your script, such as if it is an woodcutter, 'program Wood_Cutter;'. You can not have any spaces within your program name. You always need the ';' after your program name to tell the program that this is the end of the name.

The begin and end. are called your 'main loop'. What the main loop is, is your whole script. You put everything you want the program to do between the 'begin' and 'end.'.

Variables

Now, there are 5 basic variables:

Integer: Any whole number, either in the positive or the negative, e.g. 5, -32, etc.
String: A string of characters, e.g. 'Hellooo', 'blah blah', etc.
Boolean: Anything that is either true or false e.g. if your script is looking for a tree, it either finds the tree, true, or doesn't, false.
Extended: Any decimal number, e.g. 1.1, 199.52 etc.
Byte: Usually any number between one and ten.

Procedures & Functions

Procedures and functions are very similar. They are put above your main loop, and then you can incorporate them into your main loop later. Here's an example of both togeather:

program Procedure_Function_Example;

procedure Action1; //this declares this procedure as Action1

begin //beginning the procedure
dostuff; //this is not real BTW
domorestuff; //neither is this :p
end; //ending the procedure. remember, every end except the last one in the main loop always have a ; after it. The last one has a .

function Action2: boolean; //this is declaring this function as Action2. The boolean is the result

begin //beginning the function
if dostuff then //if - then means if the script did 'dostuff' then...
result := true; //...the result (the boolean we set as we named the function) will come back true
if result := true then //this is saying that if the result comes back as true, then...
domorestuff; //...the script will do 'domorestuff'. if the result doesn't come back as true, then it will skip this
end; //ending the procedure

begin //this is beginning the main loop
Action1; //this will do the procedure Action1
Action2; //this will do the function Action2
end. //ending the main loop. notice the . after the end

Variables and Constants

Constants

I took this part out of Coh3n's tut, because i liked how he explained it and don't think i could do any better of a job ;)


Constants are usually declared at the beginning of your script, and remain constant throughout your whole script, no matter where you use them, hence the name. They are declared like this, and can be used in any procedure/function throughout your script:
program New;

const
Logs = 100;

begin
end.
Pretty simple I'd say. :)

Variables

These variables are kind of a sub-category of the variables mentioned before. They can be declared in two ways. Globally, and locally. Globally it is declared the same way as constants and can be used in every procedure/function you have:

program New;

var
Logs: Integer; //this means i can use logs as an integer anywhere in my script

begin
end.

Locally means that you declare it within a procedure or function, and it can only be used in that procedure or function:

program New;

procedure Example;

var
Logs: Integer;

begin
//i can only use logs as an integer between this begin-end nest
end;

begin
end.

To give a variable a value you need to write:

variable := value
e.g.
logs := 28

remember, variables don't always need to be an integer. it could also be a string:

S := 'Hello I am Bionicle1800'

then later in your script you could use this:

WriteLn(S); //WriteLn writes the specified string in the debug box
and inside the debug box, it would look like this:
Hello I am Bionicle1800

Thank you for reading my tutorial on the basics of scar! Any questions, comments, or corrections, don't hesitate to comment below. :) and if you like my tut, use the blue check mark at the top corner of this box ;)!