Richard
2008-04-09 10:59:05
Making a basic auto-talker
I've noticed that many people like to make auto-talkers as a first script, they are simple, easy to use, and its a great way to get into scripting.
1: When you open SCAR
When you first open up SCAR you should get something that looks like this:
program New;
begin
end.This is very simple to explain, program is the scripts name, begin is the start of the script, end. is the end.
We are making an auto-talker so lets call it Talk. So we'll have
program Talk;
begin
end.2: Including SRL
If you want to make a script less detecable then the best way is to use SRL as an include, it has functions that use human-like movements so will be alot less detecable.
To put SRL into our we need a line that looks something like this:
{.include SRL/SRL.scar}We need to put that underneath the program name, but before anything else.
So we'll have:
program Talk;
{.include SRL/SRL.scar}
begin
end.So thats SRL included, moving on…
3: The constants and variables
The constant basically means something that will stay the same when running the whole script. When putting constants into scripts we put all of them under a little subheading called "Const". So lets put that in…
program Talk;
{.include SRL/SRL.scar}
Const
begin
end.Now we have to put something in the const section, the text that we want to write. When we use text in scar its known as a "string" and it is marked with using apostrophes ('). So we want our text const, lets call it text. We'll need to put = in there to show what the text is, or what the text equals. So we should now have this:
program Talk;
{.include SRL/SRL.scar}
Const
Text = 'Hello World!'
begin
end.Now we also want to add how many times we want it to type, this has to be an "integer" or whole number. When using integer we don't need anything around them, they just sit on there own. So lets call this integer "Times". So we now have:
program Talk;
{.include SRL/SRL.scar}
Const
Text = 'Hello World!';
Times = 10;
begin
end.Now we have the constants done, we need to move onto variables, variables is something that changes, or varies. We lable them in scar like consts, just we put Var at the top instead. Another thing you must learn is that with vars you need to put what type of var they are (Boolean = True or False, Strings = text storage, Integer = whole number, Extended = number with decimal places). Now we are going to need a counter for how many times it has typed. Lets call this "Typed", and this is going to be an integer, so we our script should now look like this:
program Talk;
{.include SRL/SRL.scar}
Var
Typed: Integer;
Const
Text = 'Hello World!';
Times = 10;
begin
end.4: Making it Talk
Now the most important thing about a script is that it does what it is suposed to, so in our case, it should talk.
Now, for it to talk we need to add a talking function, a good "human-like" talking function is TypeSend. It types like a human and all you need to do it put the text after it in brackets.
But, we don't want to put the text in there as we already have the text in our const section. So all we need to do is this:
TypeSend(Text);Now lets put that into a whole little procedure of its own. Procedures are like miny programs that you can then put into your main loop. They work just like main loops except you label them "procedure" instead of program, and instead of having end. you have end; as you don't want it to end the whole script.
So, lets put our talking bit into our new procedure:
procedure TalkIt;
begin
TypeSend(Talk);
end;Now, thats all great, but it will only type once, so we need it to repeat itself, we need to start the loop by putting Repeat, and end it by putting Until, and then you add some information for the util bit.
So we should have:
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Until(False);
end;You'll see we've put Until(False) in there, that means it will repeat and never stop, unless you manually stop the script. We want it to stop after its typed a certain ammount of times. Now you may remember we had the variable called Typed, now we want the variable to add on 1 every time it types, we do this by putting:
Typed := Typed + 1;Now, we want this to be put once everytime it types, so we'll have to put this after TypeSend(Text), but before the Until. So… we should have:
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Typed := Typed + 1;
Until(False);
end;Now, we need it to stop when it reaches the Const "Times" that we set, so we'll need this line.
Until(Typed >= Times);So we need to replace the Until(False) line. So the procedure should now look like this:
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Typed := Typed + 1;
Until(Typed >= Times);
end;Now we have the talking bit done, moving onto the last bit…
5: Putting it all together
So far we should have a script that looks something like this:
program Talk;
{.include SRL/SRL.scar}
Var
Typed: Integer;
Const
Text = 'Hello World!';
Times = 10;
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Typed := Typed + 1;
Until(Typed >= Times);
end;
begin
end.Now, first of all we need to put something that sets up SRL, this is very simple to do, all you need is SetupSRL, we put this into our mainloop (the begin end. bit). So we'll have:
program Talk;
{.include SRL/SRL.scar}
Var
Typed: Integer;
Const
Text = 'Hello World!';
Times = 10;
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Typed := Typed + 1;
Until(Typed >= Times);
end;
begin
SetupSRL;
end.Now we need to do something that activates the client, guess what this procedure looks like? ActivateClient :). So we'll put this after SetupSRL.
program Talk;
{.include SRL/SRL.scar}
Var
Typed: Integer;
Const
Text = 'Hello World!';
Times = 10;
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Typed := Typed + 1;
Until(Typed >= Times);
end;
begin
SetupSRL;
ActivateClient;
end.Now all we need to do is call the procedure of the talking. So we'll add TalkIt; after the ActivateClient bit. Now we should have a finished script that looks something like this:
program Talk;
{.include SRL/SRL.scar}
Var
Typed: Integer;
Const
Text = 'Hello World!';
Times = 10;
procedure TalkIt;
begin
Repeat
TypeSend(Text);
Typed := Typed + 1;
Until(Typed >= Times);
end;
begin
SetupSRL;
ActivateClient;
TalkIt;
end.So there you go, you've made an auto-talker! Have fun on your road to script greatness!