PDA

View Full Version : The Ten Minute Tutorial



cathering_
07-31-2007, 12:45 AM
--Please Post Feedback on this tutorial it only takes few seconds! --

Hey, Welcome to the Cathering way to Scar Tutorial.
Ill Be teaching you all the basics of Scar but you can continue to the more intermediate stuff like Failsafe loops and cases

This tutorial was designed to be short and sweet!


Introduction

The programming or scripting language used in scar is called Pascal so lets learn few facts about Pascal before we continue

What is Pascal?

It was named after the mathematician and philosopher Blaise Pascal.
Pascal is not new.
It was intended to teach students structured programming.
Unlike PHP or JavaScript you have to define (describe what it is) every variable ex-step variables of the constant.

Now we know what we are going to be programming in lets learn what Scar is!

What is Scar?

Scar was made by Kaitnieks a very long time ago apparently.
Scar was mainly made for Runescape cheating but still can be used for other purposes
Scar today is one the most used cheat programs for Runescape.

Ok, now we know little more about what we are programming in and what we are programming! Lets move on too what you need


What You Need
You Need Scar which you can get here (http://www.freddy1990.com/scar.php) also I recommend downloading SRL when you install Scar (Divi) which usually downloads automaticly on first starting it

Lets move on


The Scar/Pascal Syntax


program Hey;
begin
//Some Statements
end.



Okay first we have to declare are program which is necessary then we have whats called the “Main Loop” which starts at the “Begin” and ends at the “End.” notice the dot after the end, anything wrote in there will run when you click the "play" icon in scar. you can call a program anything you want as long as you have not declared the same name in the script EG


program Hey;
begin
//Some Statements
end.

program Hey;
begin
//Some Statements
end.


- Names Cannot have spaces
- Its best you keep everything lower case
- Keep to the SRL standards which can be found here (http://wiki.srl-forums.com/index.php/Scripting_Standards)
- Pascal is case-sentive (FKGfg is not the same as fkgfg) - Capital Wise
- You may not use two programs only one. or the code inside the other one will be ignored

The //Some statements is just a comment meaning scar will just ignore the text AFTER the // you can also use { } which will ignore the text INSIDE it.
below we have a example of a script that sends the string (text) "Hello World" to the debug box (the text box right below the main scripting window...


program HelloWorld;
begin
Writeln('Hello World');
end.


Write that into scar and click the play button and it will write Hello world in the debug box!

Let's Recap
Ok we know all about the Program and the begin and end. so forget about that.
The Writeln bit is whats called a procedure (notice the brakets) then you have the 'Hello World' that is what is called a string anything inside '' is called a string. Strings can contain almost any text.
then we move on to the ; The semicolon is a separator and is used to distinguish one set of instructions from another, not using this will result in a error.

- You may not use "" you must always use ''



Variables

Variables are used for storing a values, like text strings, numbers

When a variable is set it can be used over and over again in your script

Where going to learn a few of the most used ones


var
John : String;
One : Integer;
Bool : Boolean;
Percent : Extended;


Ok first of all we have tell scar where declareing a few variables so we use the "var" but this must be BEFORE the "begin" in script EG:



program Vars;
var
John : String;
One : integer;
Bool : Boolean;
Percent : Extended;
begin
//Some Statments..
end.



Ok lets learn about the types of Variables
String = Anytype of text but must be inside the ''
Integer = A Whole Number, can be Postisive or negitive
Bool = True or False statement
Extented = A extended number eg 10.11

ok now lets give them a value


program Vars;
var
John : String;
One : integer;
Bool : Boolean;
Percent : Extended;
begin
John := 'Hello';
One := 1;
Bool := true;
Percent := 10.11;
end.



Ok now lets put them to use!


program Vars;
var
John : string;
One : integer;
Bool : Boolean;
Percent : Extended;
begin
John := 'Hello';
One := 1;
Bool := true;
Percent := 10.11;
Writeln(John);
end.


Notice that we did not include any '' we just put it in but since the Writeln ONLY takes string variables we cannot use a integer, Boolean or a extended variable but what we can do
is change it into a string!!


program Vars;
var
John : string;
One : integer;
Bool : Boolean;
Percent : Extended;
begin
John := 'Hello';
One := 1;
Bool := true;
Percent := 10.11;
Writeln(IntToStr(One));
end.


We used the function inttostr to change that integer into a string there are also other conversation functions you can use.


Lets wrap this part up and move on to Operators


Operators

+ = Addition or unary positive real or integer real or integer
- = Subtraction or unary negative real or integer real or integer
* = Multiplication real or integer real or integer
/ = Real division real or integer real
div = Integer division
mod = remainder division

Logic Operators
and = if(('one' = 'one') and ('two' = 'two'))
not = if(not 'one' = 'one')
or = if(('one' = 'one') or ('two' = 'two'))

You will learn to use Operators later lets move on

Procedures

Nearly every script has at least one procedure

using procedures is easy and simple its also very similar to declaring a program!


procedure HelloWorld;
begin
Writeln('Hello World');
end;


Now look we changed the word "program" to procedure. Procedures can have there own variables that ONLY can be used by it only like below



procedure HelloWorld;
var
Hey : string;
begin
Hey := 'Hello World';
Writeln(Hey);
end;


Also notice the dot after the end has changed to a ;
now lets call the procedure!


program Hello;

procedure HelloWorld;
var
Hey : string;
begin
Hey := 'Hello World';
Writeln(Hey);
end;

begin
HelloWorld;
end.


Notice that we wrote the procedure outside the main loop because we only want to call it when we want to
Putting it in the main loop will cause a error


Procedures With Parameters

Parameters are like variables only they are given a value when you call that certain procedure lets look at this one:


HelloWorld(Hey: String);
begin
Writeln(Hey);
end;

Notice that we do not need to declare "var" but we have to define them in the brackets now lets put that procedure to good use!



program hello;

procedure HelloWorld(Hey: String);
begin
Writeln(Hey);
end;

begin
HelloWorld('Hello World!');
end.

Not much different from A normal procedure but there it is!!

-Procedures may not contain procedures in them
-Procedures cannot be put in the main loop
-Procedures must be in a program


If Statements

If statements are easy to get a hang of.

You can use conditional statements in your code to do this.

>> if...else statement - use this statement if you want to execute a set of code when a condition is true and another if the condition is not true

a simple if statement


if(condition is true) then
begin
//Some Statements
end;


Ok if the statement is true it executes the code within the begin and end that code what if its not true?
we use the else statement:


if(condition is true) then
begin
//Some Statements
end else
begin
//Some Statements
end;


if the condition is not true it will execute the else code
notice there’s no ; or . at the end statement

now we can use Operators!


if(('one' = 'one')or('two' = 'two')) then
begin
Writeln('Hello!');
end;

that’s a example of what it can do
Well that’s it that’s all I have to offer Good luck!
- Also keep to the SRL Standards found here (http://wiki.srl-forums.com/index.php/Scripting_Standards)

lolpie
07-31-2007, 02:16 AM
Wow, one of the better tuts out there. Good job and +rep

cathering_
07-31-2007, 02:20 PM
Unexpected reply, but thanks!

passiondrive
07-31-2007, 07:00 PM
Cathering_, your determination and drive are to be respected, I've never seen a newcomer to SCAR move on as quickly as you. GREAT tut and plus repped. Extremely well done. (I say newcomer... I've not exactly been here years)

Spky
07-31-2007, 07:08 PM
Good job.
The Cathering way the Scar should include standards, though.

cathering_
07-31-2007, 07:17 PM
@Passion it looks like your liveing up to your name nice speech!

and thanks :P


@Spky thanks , are you talking about That it should tell people to use SRL standards? (Its in the Scar / Pascal Syntax bit ive added link now.

Johura
08-03-2007, 09:50 AM
Standards is just a way to keep your script nice and neat for easy reading. Example:
This:
program hello;

procedure HelloWorld(Hey: String);
begin
Writeln(Hey);
end;

begin
HelloWorld('Hello World!');
end.


Should be:

program hello;

procedure HelloWorld(Hey: String);
begin
Writeln(Hey);
end;

begin
HelloWorld('Hello World!');
end.


Notice how things in Bold are in lower case and after every Bold word we put 2 spaces? Thats basically 'scar standards'.

cathering_
08-04-2007, 03:03 AM
I know what the SRL standards are but If you insist that I indent the code I will do it at least you posted feedback :)

Korbman
08-09-2007, 02:46 PM
Very nice! Compared to some of the other tuts i've read, I think this on is better on going over the basics. Good job! :p

cathering_
08-09-2007, 06:39 PM
Thanks, Ive edited it again , to fix some spelling and change some improper senteces (the word "browser") XD I also tried to try my best to explain variables as alot people find it confuseing ? well i did at first XD

soggys
08-13-2007, 08:26 AM
[QUOTE=cathering_;172278]--Please Post Feedback on this tutorial it only takes few seconds! --

What You Need
You Need Scar which you can here

small typo that you've made lol^^^ oh well very good tut. ive been watching SCAR grow for a while now... used it once or twice but ive only just started using it more permanently and decided that scripting was something i would like to do so here i am... very useful tut and im expecting to be using it a lot in the near future... much rep+

haha i made a spelling error too *irony*

cathering_
08-13-2007, 10:59 AM
Thanks, Yeah lol i edited the typo, only fate can decide if it willl be used in near future :P

decilios
08-13-2007, 04:34 PM
Nice tutorial! A good start for a noob like me:p

Emagdnim
08-13-2007, 04:35 PM
Ya thx a lot book marking this right now.

PwNZoRNooB
08-14-2007, 05:31 AM
Nice looking tutorial.

cathering_
08-15-2007, 04:23 AM
@ The Three New Replys - Thanks, Hmm i thinking of adding a bit more on operators, I also thougth That the words would be to complex and you would'et under stand them it turned out somewhat different :S

tristanrulz
08-24-2007, 08:18 AM
come u plz post link to dowload srl?

inkd
08-24-2007, 03:14 PM
good tut thnx!

is this a little mis type?

"Lets warp this part up and move on to Operators"

should be wrap? hehe.

still good tut thnx for creating it.

cathering_
08-25-2007, 06:33 PM
@ tristanrulz -> Eyes, Theres a forum saying "Download SRL Here".

@ inkd -> Thanks, And yeh thats a miss type XD , and hmm I think the giant text saying "Please Post Feedback This Tutorial" Helped

srl user
09-05-2007, 03:39 AM
Nice effort. FYI: there are still quite a few grammatical, punctuation, spelling and typo errors. Fixing them would improve the readability, though they are common in the tutorials in this forum, so I have come to expect them (and I am prone to them too). :D

You could do what I sometimes do, which is copy and paste the text into Microsoft Word or another program with a spelling and grammar checker and run those checks on the text, fixing it, then paste it back into your edited post.

Elmo_Time
09-05-2007, 04:53 PM
this guide is really helpfull thanks:google:

desolator416
09-05-2007, 08:31 PM
Yeah, good tutorial. I've been thinking about learning to program in SCAR for awhile now, but alot of the things I've seen about it so far look really daunting and make my head hurt. I'll be adding this to my Pascal tutorial pile.

:spot:

cathering_
09-08-2007, 01:12 AM
@ srl_user -> Im going to edit the grammer and add new things to it when i finish my script im working on.

@ Elmo_Time -> Thanks :p

@ Desolator -> Its good to know your trying to learn it, Althougth if your search the web for 'pascal tuts' I would not reccomend it as Scar Is a extended Verison for pascal and just because a Pascal Script compiles in anohter pascal compiler dose not mean it would in scar.