SRL Archive - Outdated Tutorials

Your first script - Very Detailed


Ares

2006-06-04 14:26:06

If not done already, download the SCAR program: http://www.forums.drewley.net/showthread.php?p=199#post199

Ok, to get you going, this tutorial will help you setup your first script, a classical autotyper.

1. First things first, open a new page up…

2. Insert this in line 1:
 Program Autotyper; 
This is the name of your script; you can set this to what ever you want, but make it relivent if you plan on sharing your script.

3. Press enter to get onto the next line. Type in:
var message: string;
This is telling the script to create a changeable srting(text) value. "Message" can be chnaged to what ever you want, just make sure you remmeber what the value is for.

4.Press enter twice until you get to line 4; now type in:
Procedure setup;
, this tells the script to start a new procedure or task, i always call my first one "setup" as it normally is the part of the script which the user has to modify/ setup, hence the name.

5. You should now have this:

line1: Program Autotyper;
line2: var message: String;
line3:
line4: Procedure setup;

6. Next thing, after line 4 type in:

line5: begin
line6: message:= 'Message here' // Enter your message inbetween the "s.
line7: end;
The "Begin" command tells the script to begin the procedure.
"message:= 'Message here' " is setting the value of "message", this is going to be the message which the autotyper will type.
"end;" is the command to end the procedure.

7. Press enter twice… Make sure you space out your scripts, it becomes easier to manage.
Then type in this code:

Procedure typing;
begin
sendkeys(message + chr(13));
end;
-"procedure type" thats the name of the procedure.
-"Begin", again tells the script to begin the procedure.
-"Sendkeys(message)" this is telling to script to type in the message of "Message" which the user has set in the setup procedure.
-"+chr(13)" means to add key "enter" after the message.
-"end;" again tells the script to end the procedure.

8. After that, again press enter twice. Then insert this code:

begin
setup;
repeat
typing;
wait(2000)
until(false)
end.
Because this is the main loop procedure we do not need to put "procedure bluh;".
"setup;" is calling the setup procedure, we place this outside the repeat(loop) so it doesn't cause the cript to malfunction.
"repeat" tells the script to repeat the code underneath for a set amount of time, it is stopped by "until()".
"type;" is telling us to run the type procedure, because its underneath the "repeat" function this procedure will be looped.
"wait(2000)" tells the script to pause for 2 seconds (1000=1sec, 4000=4 secs etc).
"until(false)" tells the script when to stop repeating, "false" means is continuous and doesn't stop until maunally done.
"end." is the final end command, its always witha "." insteda of ";" because it means the script should stop there.

9. Now you hould have this code:

Program autotyper;
var message: String;

procedure setup;
begin
message:= 'Message here' // Insert message inbetween "s
end;

procedure typing;
begin
sendkeys(message +chr(13));
end;

begin
setup;
repeat
typing;
wait(2000)
until(false)
end.


Tips:
1. "//" allows you to add comment into the script, these are normally use for instructions within a script. These only work for single line comments.
2. A list of "chr()" can be found in one of the test scripts when you install scar (pm for more help)
3. Always space out your script. Even use indenting if possible (just press tab after enter)

Hope this helps, Post any comments or if ive missed bits oout just post em here.

Janilabo

2006-06-07 08:15:22

Yes. You have explained very well the things you've included to your tutorial. Nice little tutorial. Good job! :)

phantombmx

2006-06-07 17:33:13

ahhH! dont teach people bad standards from the beginning!

Ares

2006-06-07 17:55:42

lol, soz, i dont know slr, so i cant teach it, lol, im still on scar 1.04 knowledge in my world, i need to reteach myself after my exams :D

HarryJames

2007-04-27 18:30:54

good tut, good luck with your exams

PacManFtw

2007-04-28 16:11:39

good tut, hope you can include SRL for n00bs like me soon :P

Skalla

2007-08-04 08:59:17

Great tutorial :) i really learned something here.

im trying to become a good scar scripter. :bart:

I B X R

2007-08-31 00:21:29

Hmmm, honestly, I thought I could have made a better guide. :(

masterBB

2007-09-13 16:20:49

A very… very… very… short tut.. but it's clear… not briliant but good…

the only new thing you told me was the piece where you can find all the chr() things.

masterbb

1-DUB

2007-09-16 15:21:23

nice work, this will help many people such as my self that are just starting to script

ShowerThoughts

2007-09-16 15:24:18

lol why use a setup procedure just use a const;)

Juitar1

2007-09-16 20:50:42

nice, tut. clear, and to the point! :-)

applesauce121

2007-09-16 23:59:13

Great Tut!! Learned a lot about scar from this

Eugeniu

2007-09-18 15:06:57

Great tutorial. I love it how you explain everything in detail. I wanna learn to script in scar soooo badly….

AsainOwnz

2007-09-18 22:04:38

nice guide

Hasslarn

2007-09-22 05:32:18

Best Guide Ever Thnx Alot man :)

i just made a autotyper yeeiii