Awkwardsaw
2009-07-01 00:11:42
This is my first tut, and i figured this was a good place to start
i know there are a lot of these, but a lot of them aren't finished/ don't have all the things beginers need to know to make their first script
so, lets start out with the table of contents, shall we?
Table of Contents
Intro
OK, first off, I'm awkwardsaw :) and i will try my best to teach you the basics of scripting in Simba and SRL. i am expecting you to already have Simba, and SRL downloaded, and know how to start, stop, set client, and use the color picker components in Simba.
Shall we get started? :D
Basics of Basics
OK, open up Simba, and you see this:
these are the VERY basics of EVERY script, you're probobly wondering what they are, and why we need them so i will explain it =D
program New;
this is simply the begining of the script, it is always the first line of the code.
"New" is what you call the script, you can change it to what ever you want, for demonstration purposes i'll name it MahFirstScript
Now that you understand what that is, lets go to that funny looking pair of words; Begin and end.
Begin Is the BEGINNING of the main loop, which is simply the "Main Command Center" of the script, this is where things do what they do, and with out it the script will do nothing
End. is well, you guessed it, the END of the script, and main loop.
so now, we have this:
just incase your wondering, the words in green are called "comments". these are exactly that.
Hello World!
yes, you heard me, say hello to the world of scripting! not out loud though, people might here you :(
Finally! the part you have been waiting for! we are going to make your very first script! it wont be very use full, and no one would think anything of it(except you of coarse, but you have every right too :))
BUT its a start
This is the first command that you will learn about. writeln is simply a procedure that writes the given string(the stuff thats between the ' ') into the debug box.
well, if you looked at it, you would notice that its called "wait". all this does is, you guessed it, wait for the given milliseconds(yes, it has to be in milliseconds)
i added not one, but TWO new things to it, the first is cleardebug, which simply clears the debug box, and + random(100) which adds a random number between 0-100 to 1000
Variables
there are 4 main types of variables, that every scripter knows about. Variables can be changed during script run time. they are called:
Integer: simply any whole number, cannot be a decimal, pretty simple, no?
Strings any word or text, including special characters, letters, and numbers.
Boolean Simply put, its true or false, nothing to special, but very usefull
Extended Any number, that is not a whole number(decimal). i believe the highest decimal place that it can hold is to the 19th spot(0.0000000000000000001)
how you use variables can get confusing, but they are, like every thing so far, needed in every decent script :P
i tried to explain every thing in there, play around with it untill you get how evey thing works. change the variable settings or add more variables if you like. I will cover other variables later on in this tut
Constants
Constants are what most scripters use as a "set up" in their scripts. they cannot be changed during run time. but, they are used like variables, as n they store info in either integer, extended, string, or boolean. not much else to go over exept how to use them, which i am about to go over :)
once again, i tried to explain every thing as before. continue to play around with variables and consts
Hello world! using Variables and Constants!
what this script does, is it waits for how ever long you specify, and adds 1 to the variable 'i'. at the end it says how many commands you used, based off of how much i equals. we will go even more into detail with this in the following sections :D
If-Then-Else, and Cases
ooo boy. these are fun, these also remind me of first semester geometry, which isnt so fun :(
why yes, we are talking about If-Then Statements!
first, you will have to understand WHAT an if-then-else statement is(known as a conditional statement)
before you can understand, you will need to know some vocabulary
if and then.
if is a hypothesis, which is "asking a question" pretty much
then is a conclusion, which is "answering" your question.
here is an example:
if my name is dan, then the first letter is D.
this means, that if my name is dan, then the first letter is ALWAYS D.
simply put in Conditional statement terms,
if Lunch is Tacos, then we are having tacos for lunch.
the inverse(else) means
if lunch is not tacos, then we are not having tacos for lunch
get it? i hope so, because i cant really explain the concept of conditional statements any better
an other way to look at that little example, is
time to get more advanced using these statements :P
"oh my god! you said advanced! not SUPER ADVANCED!" well chill, this may be hard to read at first, but take a chill pill and let me explain things!
first off, we have lunch set to tacos, and eat set to true in our constants.
our variables are "S, and SS". they are strings
before we do any thing, the script checks if you want to eat, which i set to true in the constant. if it is true, the S is set to "we are eating", if not, it is set to "we are not eating" and it says so in the debug box.
next, it checks if we are eating tacos, using the same method as above.
there is a way to make this look a lot neater, and more accepted in the SRL community! these magicle things are called "cases"
i think its self explanitory, i cant really think of any way to explain this better than example :(
cases are used very often, mostly in antiban and it makes HUGE conditional statements a lot neater, and cleaner, and efficient :)
Loops!
loops are what make scripts run for how long they do, as in the repeat them selves until it is told to break out.
there are 3 main types of loops, repeats, while-do, and goto loops. all of them have their different purposes.
lets start with the basic and first loop, repeats!
lets start from the beginning. R is our integer variable.
repeat is the loop that we use
in the loop it increases R by 1, waits 1000 milliseconds and writelns the cycle that its on.
until says that it will keep going through the cycles until r gets to 10.
its pretty simple, and it does get more and more advanced the more you get used to using it.
Our next loop is While-do loops. they are a little harder to understand, yet also very usefull.
in this, all we want to look at is while R <= 10 do inc(r);
what this does is, while R is less than or equal to 10, it increases it by 1 until it is. and then when it is it says so.
GoTo loops. they are great in some ways and they are looked down upon in others, yet they do have their place in here.
go to loops can get very complex, and confusing, and most people look at them as "Advanced looping", although if used right they are very simple and use full.
looks kind of scary doesnt it? when i first learned about it, i thought it was too, untill i played around with it
every thing should be explained in the example, but imma break it down.
Label just says that your calling a label.
GoBack is the name of the label
GoBack: is where it goes back to, when told
if Count < 5 then goto GoBack; is what tells the script to go back to the label
Procedures and Functions!
this is where you REALLY start to have some fun! and im not kidding. procedures and functions are where you separate the "20 line script that sucks and does one thing" to the "500+ ub3r script that's amazing and i would want to marry".
of course, we will start out simple.
a procedure is exactly that, a procedure that is told to do something
a function is like a procedure, exept it returns a value in the form of a variable
which one you use is up to the circumstance.
this also may seem scary, but look through the example and play around with it. make it do some different things, change the numbers, ect ect.
the first part of the procedure is: procedure dothis. it simply calls the procedure and gives it a name.
like the main loop, the commands need to start with a BEGIN and end with an end;(not end. end. ends the script, end; ends the procedure/ section. you have to remember that)
Advanced Procedures and Functions!
this is section will teach you how to make more advanced and usefull procedures and functions.
first, lets make a little "debugger" procedure, which can help debug some future scripts :P
the procedure DeBugThis(procname: string); is my procedure.
Debugthis is the procedure name, and the stuff between the ( ) are the parameters, its what makes the procedure do what it does.
i made the parameter return a string, so you can right what ever you want in as a string, an it will writeln it into the debug box.
look through the example so you can try to get it ;)
now for the function:
its the same thing as the procedure, except this has 2 parameters, that are integers instead of strings. you should already know how the function its self works
Basic Failsafes
this section will teach you about basic failsafes. failsafes are just as important to any script as your main loop.
fail safes are the things that catches the script if it messes up, and usually fixes it.
we already used fail safes in loops, to make sure that the loop stopped when it needed to stop, but this will go further into the actual fail safe.
note: this script will not compile, i just made it as an example.
dont pay much attention to the find ax procedure, because that's not where the fail safe is :P
study the cuttree procedure, that first checks if it has the ax, if it doesnt it looks for it, if it doesnt find it within 10 checks, it goes and gets one, and then when it does have an ax it starts cutting the tree :)
theres really nothing else "basic" about failsafes, because all you really need to know is the concept of it.
and this brings us to the LAST section of the tut, where we can put all of this stuff together, and hopefully make this stuff "click" in your heads.
i will give you a step by step tut on how to make your very own auto-login script!
Making your first script
This part of the tutorial is OUTDATED. DO NOT try to use this script in RuneScape!!!(although studying and learning how it works will still help you tremendously :)
first things first, open up a new script document, and save it as "My First RS script". it can be w/e you want, but hey =p
next, we need to include SRL to the script, so we can use it
just copy and paste that in. remember to include srl when ever you script with it :D
Next, lets make our Constants.
make a username, and password constant, and make it a string
then, lets check if we are at the welcome screen(the part where you log in)
so, in order to check if we are at it, we will use two different colors in 2 different areas. i used the procedure FindColor(x, y, color, x1, y1, x2, y2).
FindColor is the name of the procedure, x, y, are the variables that it stores the coordinate of the color to, color is obviously the color, and x1, y1, x2, y2 is the box it looks for the color in, from top left to bottom right. Get your own coord and color if you want. then use an if-then statement to look for it, like so
after you have that and understand how it works(and hopefully your own colors and coords :p)
lets make the LogIn procedure.
after that, make your own fail safe to make sure that your at the Welcome screen, don't be afraid to go back up and look at an example :)
so far, this is what i have in the procedure:
hopefully your not just copying and pasting my stuff and thinking your learning, ;P im doing this so you can learn you know, :)
next, just to make it look nicer, lets make a different procedure that actually logs you in:
to make this, you need to know 'bout typesend!
typesend is what you use to type things into rs(since it hits enter after it types your message)
this is my procedure:
next we put it into the LogIn procedure:
after you get this and understand it fully, lets wait for the "click to log in" button.
i made this function to check if it is or not:
the only new thing in this procedure was mousebox. what it does is if click a random coordinate within the given box. the 1 at the end tells it to left click. 2 means right click and 3 means just hover.
now lets add it to the login procedure using a while-do loop ;P
now we are done! here is my final product:
now was that so hard? :)
Conclusion
that raps up my very firsrt scripting tutorial :D
post any feed back what so ever, even if you hate this tut, wish i would die in a fire, ect ect.
remember, stuff in this tut are only the BASICS of Simba and srl. there are HUNDREDS of different procedures, functions, and commands that you can utilize and learn.
If i get good enough feed back, i will think about making an other volume to this tut, that goes into more detail and more advanced stuff.
PM me on the forums or post here in this topic if you would like some help, or add me on msn: [email]akwardsaw@hotmail.com[/email]
Credits
First of all, i would like to thank the entire SRL community for helping out when i was a newby at scripting, and took the time to answer my countless and obvious questions :D
then, i would like to thank the people who wrote their awesome tuts, and made me learn even further about scripting.
the last "thank you" is for the srl members who voted no on my membership application a few months ago, you made me learn more about scripting and expect an uber script to come your way soon
Recommended Links
Unmatched beginers guide to scar This helped me out LOADS when i started to begin scripting, i recommend you read it too
How To Fix annoying scar errors. made by JAD, saved me LOADS of time and frustration, beileve me
Making your own includes pretty cool tut
~akwardsaw :norris:
i know there are a lot of these, but a lot of them aren't finished/ don't have all the things beginers need to know to make their first script
so, lets start out with the table of contents, shall we?
Table of Contents
- Intro
- Basic Basics
- Hello World!
- Variables
- Constants
- Hello world! Using Variables and Constants
- If-Then-Else, and cases
- Loops
- Procedures and Functions
- Advanced Procedures and Functions
- Basic Fail safes
- Making your Very first RS script!
- Conclusion/credits/links
Intro
OK, first off, I'm awkwardsaw :) and i will try my best to teach you the basics of scripting in Simba and SRL. i am expecting you to already have Simba, and SRL downloaded, and know how to start, stop, set client, and use the color picker components in Simba.
Shall we get started? :D
Basics of Basics
OK, open up Simba, and you see this:
program New;
begin
end.these are the VERY basics of EVERY script, you're probobly wondering what they are, and why we need them so i will explain it =D
program New;
this is simply the begining of the script, it is always the first line of the code.
"New" is what you call the script, you can change it to what ever you want, for demonstration purposes i'll name it MahFirstScript
Now that you understand what that is, lets go to that funny looking pair of words; Begin and end.
Begin Is the BEGINNING of the main loop, which is simply the "Main Command Center" of the script, this is where things do what they do, and with out it the script will do nothing
End. is well, you guessed it, the END of the script, and main loop.
so now, we have this:
program MahFirstScript;// program name
begin//Begining of the Main loop
end.// End of the Main loopjust incase your wondering, the words in green are called "comments". these are exactly that.
//comments are very use full, and can be called in very different ways
{sometimes they are called like this,
using brackets. any thing within the brackets
will be commented out like so}
Hello World!
yes, you heard me, say hello to the world of scripting! not out loud though, people might here you :(
Finally! the part you have been waiting for! we are going to make your very first script! it wont be very use full, and no one would think anything of it(except you of coarse, but you have every right too :))
BUT its a start
program MahFirstScript;
begin
writeln('Hello World!');
end.This is the first command that you will learn about. writeln is simply a procedure that writes the given string(the stuff thats between the ' ') into the debug box.
program MahFirstScript;
begin
writeln('Hello World!');
wait(1000);
writeln('gee, isnt this fun?');
end."oh noes! you added something else in there! what can it possibly mean?"well, if you looked at it, you would notice that its called "wait". all this does is, you guessed it, wait for the given milliseconds(yes, it has to be in milliseconds)
program MahFirstScript;
begin
cleardebug;
wait(1000 + random(100));
writeln('Hello World!');
wait(1000 + random(200));
writeln('gee, isnt this fun?');
wait(1000);
end.i added not one, but TWO new things to it, the first is cleardebug, which simply clears the debug box, and + random(100) which adds a random number between 0-100 to 1000
Variables
there are 4 main types of variables, that every scripter knows about. Variables can be changed during script run time. they are called:
Integer: simply any whole number, cannot be a decimal, pretty simple, no?
Strings any word or text, including special characters, letters, and numbers.
Boolean Simply put, its true or false, nothing to special, but very usefull
Extended Any number, that is not a whole number(decimal). i believe the highest decimal place that it can hold is to the 19th spot(0.0000000000000000001)
how you use variables can get confusing, but they are, like every thing so far, needed in every decent script :P
program MahFirstScript;
var //you must say this to call a variable
I: integer; // this calls I to an integer variable
S, S1: String; // and this makes S and S1 a String variable
begin
cleardebug; // clear debub box
I:= 1000; //sets the variable I to 1000
S:= 'lolwut'; //sets tge variable S
S1:= 'Do you get it? if not, play around some more'; //sets the variable S1
wait(I + random(i)); //waits for the specified amount, which was set by I
writeln(S); //writes what ever S is
wait(i + random(i)) ;
writeln(s1);//says what ever S1 is
wait(i);
end.i tried to explain every thing in there, play around with it untill you get how evey thing works. change the variable settings or add more variables if you like. I will cover other variables later on in this tut
Constants
Constants are what most scripters use as a "set up" in their scripts. they cannot be changed during run time. but, they are used like variables, as n they store info in either integer, extended, string, or boolean. not much else to go over exept how to use them, which i am about to go over :)
program MahFirstScript;
const
Text = 'lol, consts are fun'; //this is a string const
Number = 100; //this is an integer const
begin
cleardebug;
wait(Number); //waits for what ever you said Number is
writeln(Text); //same as above
wait(Number);
end.once again, i tried to explain every thing as before. continue to play around with variables and consts
Hello world! using Variables and Constants!
program MahFirstScript;
const
Text = 'lol, consts are fun'; //this is a string const
Number = 100; //this is an integer const
var
I :integer;//integer variable
S: string;//string variable
begin
cleardebug;
inc(i);//this adds one to what ever i equals. at the begining of the script, all integer values = 0, untill specified otherwise
wait(Number);//waits for how ever long you want
inc(i);
writeln(Text);//says what ever text you want
inc(i);
S:= inttostr(i); //this converts an integer "i" to a string, "s"
writeln('this script has done ' + S + ' commands!'); self explanitory
end.what this script does, is it waits for how ever long you specify, and adds 1 to the variable 'i'. at the end it says how many commands you used, based off of how much i equals. we will go even more into detail with this in the following sections :D
If-Then-Else, and Cases
ooo boy. these are fun, these also remind me of first semester geometry, which isnt so fun :(
why yes, we are talking about If-Then Statements!
first, you will have to understand WHAT an if-then-else statement is(known as a conditional statement)
before you can understand, you will need to know some vocabulary
if and then.
if is a hypothesis, which is "asking a question" pretty much
then is a conclusion, which is "answering" your question.
here is an example:
if my name is dan, then the first letter is D.
this means, that if my name is dan, then the first letter is ALWAYS D.
program MahFirstScript;
const
Lunch = 'Tacos';
begin
if Lunch = 'Tacos' then
writeln('We are having tacos!') else
writeln('awww, we arent having any tacos today =[');
end.simply put in Conditional statement terms,
if Lunch is Tacos, then we are having tacos for lunch.
the inverse(else) means
if lunch is not tacos, then we are not having tacos for lunch
get it? i hope so, because i cant really explain the concept of conditional statements any better
an other way to look at that little example, is
program MahFirstScript;
const
Lunch = 'Tacos';
begin
if Lunch = 'Tacos' then
writeln('We are having tacos!');
if not Lunch = 'Tacos' then
writeln('we are not having tacos');
end.time to get more advanced using these statements :P
program MahFirstScript;
const
Lunch = 'Tacos';
eat = true;
var
S, SS: string;
begin
if eat = true then
S:= 'we are eating!';
else
S:= 'we are not eating';
writeln(S);
if Lunch = 'Tacos' then
SS:= 'we are eating tacos!';
else
ss:= 'we are not eating tacos';
writeln(SS);
end."oh my god! you said advanced! not SUPER ADVANCED!" well chill, this may be hard to read at first, but take a chill pill and let me explain things!
first off, we have lunch set to tacos, and eat set to true in our constants.
our variables are "S, and SS". they are strings
before we do any thing, the script checks if you want to eat, which i set to true in the constant. if it is true, the S is set to "we are eating", if not, it is set to "we are not eating" and it says so in the debug box.
next, it checks if we are eating tacos, using the same method as above.
there is a way to make this look a lot neater, and more accepted in the SRL community! these magicle things are called "cases"
program MahFirstScript;
const
Lunch = '';
eat = true;
begin
case eat of
true: writeln('we are eating!');
False: writeln('we are not eating!');
end;
case Lunch of
'Tacos': writeln('we are eating tacos!');
'': writeln('oh, i guess we arent eating anything after all');
'beef': writeln('we are eating beef! mmmmmmm!');
end;
end.i think its self explanitory, i cant really think of any way to explain this better than example :(
cases are used very often, mostly in antiban and it makes HUGE conditional statements a lot neater, and cleaner, and efficient :)
Loops!
loops are what make scripts run for how long they do, as in the repeat them selves until it is told to break out.
there are 3 main types of loops, repeats, while-do, and goto loops. all of them have their different purposes.
lets start with the basic and first loop, repeats!
program MahFirstScript;
var
R: integer;
begin
cleardebug;
repeat
inc(r);
wait(1000);
writeln('this is on the ' + inttostr(r) + ' cycle');
until r = 10;
end.lets start from the beginning. R is our integer variable.
repeat is the loop that we use
in the loop it increases R by 1, waits 1000 milliseconds and writelns the cycle that its on.
until says that it will keep going through the cycles until r gets to 10.
its pretty simple, and it does get more and more advanced the more you get used to using it.
Our next loop is While-do loops. they are a little harder to understand, yet also very usefull.
var
R: integer;
begin
writeln('R is less than 10');
wait(2000);
while R <= 10 do inc(r);
wait(1000);
writeln('R is now equal to or greater than 10');
end.in this, all we want to look at is while R <= 10 do inc(r);
what this does is, while R is less than or equal to 10, it increases it by 1 until it is. and then when it is it says so.
GoTo loops. they are great in some ways and they are looked down upon in others, yet they do have their place in here.
go to loops can get very complex, and confusing, and most people look at them as "Advanced looping", although if used right they are very simple and use full.
program lblTest;
label //calls the label
GoBack; //the label name
var
Count: Integer;
begin
GoBack: //this is where you "GoTo"
Count := Count + 1;
WriteLn('Hello, ' + inttostr(count));
if Count < 5 then goto GoBack; //if Count is less than 5, then it GoTo's the label
end.looks kind of scary doesnt it? when i first learned about it, i thought it was too, untill i played around with it
every thing should be explained in the example, but imma break it down.
Label just says that your calling a label.
GoBack is the name of the label
GoBack: is where it goes back to, when told
if Count < 5 then goto GoBack; is what tells the script to go back to the label
Procedures and Functions!
this is where you REALLY start to have some fun! and im not kidding. procedures and functions are where you separate the "20 line script that sucks and does one thing" to the "500+ ub3r script that's amazing and i would want to marry".
of course, we will start out simple.
a procedure is exactly that, a procedure that is told to do something
a function is like a procedure, exept it returns a value in the form of a variable
which one you use is up to the circumstance.
program procfunttest;
const
number = 1;
number2 = 2;
procedure dothis; //this sets the procedure, and the name
begin
writeln('this is a procedure'); //this is what you want it to do//
wait(1000); //////////////////////////////////
writeln('neat, huh?'); //////////////////////////////////
end;
function checkthis: integer; //this is a function, and the result of it is a integer
begin
writeln('doing some maths'); //you can make functions do commands just like procedures
wait(1000);
result:= number + number2; //this sets the result, every function needs to have one
end;
begin
cleardebug;
dothis; //this is the procedure that we made
wait(1000);
writeln(inttostr(checkthis)); //and this writelns the result of the function "checkthis"
end.this also may seem scary, but look through the example and play around with it. make it do some different things, change the numbers, ect ect.
the first part of the procedure is: procedure dothis. it simply calls the procedure and gives it a name.
like the main loop, the commands need to start with a BEGIN and end with an end;(not end. end. ends the script, end; ends the procedure/ section. you have to remember that)
Advanced Procedures and Functions!
this is section will teach you how to make more advanced and usefull procedures and functions.
first, lets make a little "debugger" procedure, which can help debug some future scripts :P
program procfunttest;
const
number = 1;
number2 = 2;
var
i: integer;
procedure DeBugThis(ProcName: string);
begin
inc(i);
writeln(ProcName + ' ' + inttostr(i));
writeln(' ');
end;
begin
DeBugThis('Beginning of MainLoop');
wait(1000);
DeBugThis('finished wait');
end.the procedure DeBugThis(procname: string); is my procedure.
Debugthis is the procedure name, and the stuff between the ( ) are the parameters, its what makes the procedure do what it does.
i made the parameter return a string, so you can right what ever you want in as a string, an it will writeln it into the debug box.
look through the example so you can try to get it ;)
now for the function:
program procfunttest;
function AddThis(Number, Number1: integer): integer;
begin
result:= Number + Number1
end;
begin
writeln(inttostr(addthis(5, 5)));
end.its the same thing as the procedure, except this has 2 parameters, that are integers instead of strings. you should already know how the function its self works
Basic Failsafes
this section will teach you about basic failsafes. failsafes are just as important to any script as your main loop.
fail safes are the things that catches the script if it messes up, and usually fixes it.
we already used fail safes in loops, to make sure that the loop stopped when it needed to stop, but this will go further into the actual fail safe.
program FindElTree;
var i: integer;
function FindAx: boolean;
begin
code here and such;
thisstufffindsanax
if foundax then
result:= true;
end;
procedure cuttree;
begin
if not findax then
begin
repeat
FindAx;
inc(i);
until (FindAx = true or i = 10);
if FindAx = false and I = 10 then GetAx;
end;
Cuttingtreestuff;
end;
begin
cuttree;
end.note: this script will not compile, i just made it as an example.
dont pay much attention to the find ax procedure, because that's not where the fail safe is :P
study the cuttree procedure, that first checks if it has the ax, if it doesnt it looks for it, if it doesnt find it within 10 checks, it goes and gets one, and then when it does have an ax it starts cutting the tree :)
theres really nothing else "basic" about failsafes, because all you really need to know is the concept of it.
and this brings us to the LAST section of the tut, where we can put all of this stuff together, and hopefully make this stuff "click" in your heads.
i will give you a step by step tut on how to make your very own auto-login script!
Making your first script
This part of the tutorial is OUTDATED. DO NOT try to use this script in RuneScape!!!(although studying and learning how it works will still help you tremendously :)
first things first, open up a new script document, and save it as "My First RS script". it can be w/e you want, but hey =p
next, we need to include SRL to the script, so we can use it
program New;
{.include SRL/SRL.scar}
begin
end.just copy and paste that in. remember to include srl when ever you script with it :D
Next, lets make our Constants.
make a username, and password constant, and make it a string
program New;
{.include SRL/SRL.scar}
const
Username = '';
Password = '';
begin
end.then, lets check if we are at the welcome screen(the part where you log in)
function AtWelcomScreen: Boolean;
begin
end;so, in order to check if we are at it, we will use two different colors in 2 different areas. i used the procedure FindColor(x, y, color, x1, y1, x2, y2).
FindColor is the name of the procedure, x, y, are the variables that it stores the coordinate of the color to, color is obviously the color, and x1, y1, x2, y2 is the box it looks for the color in, from top left to bottom right. Get your own coord and color if you want. then use an if-then statement to look for it, like so
function AtWelcomScreen: Boolean;
var a, b, w, z: integer;
begin
if FindColor(a, b, 13158, 356, 180, 406, 194) and
FindColor(w, z, 10669529, 287, 164, 476, 201) then
result:= true;
end;after you have that and understand how it works(and hopefully your own colors and coords :p)
lets make the LogIn procedure.
procedure LogIn;
begin
end;after that, make your own fail safe to make sure that your at the Welcome screen, don't be afraid to go back up and look at an example :)
so far, this is what i have in the procedure:
procedure LogIn;
var i : integer;
begin
if not AtWelcomeScreen then //start of fail safe
begin
writeln('not at welcome screen yet');
repeat
wait(3000 + random(400));
inc(i);
until (Atwelcomescreen = true or i = 10 + random(3));
if i >= 10 then begin
writeln('Still not at Welcome Screen, exiting');
exit; //exits the procedure
end;
end; //ends the fail safe
end;//ends procedurehopefully your not just copying and pasting my stuff and thinking your learning, ;P im doing this so you can learn you know, :)
next, just to make it look nicer, lets make a different procedure that actually logs you in:
LogMeIn(name, pass: string);to make this, you need to know 'bout typesend!
typesend is what you use to type things into rs(since it hits enter after it types your message)
this is my procedure:
procedure LogMeIn(name, pass: string);
begin
wait(1000 + random(5000));
typesend(' ');//just hits enter, so it goes to the log in screen
wait(100 + random(2200));
typesend(name); //types your user name, and hits enter to go to the password
wait(200 + random(2201));
typesend(pass); //types password and hits enter so you log in
wait(1000 + random(2000)); //just a wait
end;every thing is explained in the example ;)next we put it into the LogIn procedure:
procedure LogIn;
var i : integer;
begin
if not AtWelcomeScreen then
begin
writeln('not at welcome screen yet');
repeat
wait(3000 + random(400));
inc(i);
until (i = 10 + random(3)) or Atwelcomescreen;
if i >= 10 then begin
writeln('Still not at Welcome Screen, exiting');
exit;
end;
end;
LogMeIn(UserName, Password);
end;after you get this and understand it fully, lets wait for the "click to log in" button.
i made this function to check if it is or not:
function clickheretoplay: boolean;
var a, b: integer;
begin
if FindColor(a, b, 1647915, 214, 413, 563, 449) then
begin
result:= true;
mousebox( 214, 413, 563, 449, 1);
end;
end;the only new thing in this procedure was mousebox. what it does is if click a random coordinate within the given box. the 1 at the end tells it to left click. 2 means right click and 3 means just hover.
now lets add it to the login procedure using a while-do loop ;P
procedure LogIn;
var i : integer;
begin
if not AtWelcomeScreen then
begin
writeln('not at welcome screen yet');
repeat
wait(3000 + random(400));
inc(i);
until (i = 10 + random(3)) or Atwelcomescreen;
if i >= 10 then begin
writeln('Still not at Welcome Screen, exiting');
exit;
end;
end;
LogMeIn(UserName, Password);
while not clickheretoplay do wait(100 + random(100));
end;now we are done! here is my final product:
program New;
{.include SRL/SRL.scar}
const
Username = '';
Password = '';
function AtWelcomeScreen: Boolean;
var a, b, w, z: integer;
begin
if FindColor(a, b, 13158, 356, 180, 406, 194) and
FindColor(w, z, 10669529, 287, 164, 476, 201) then
result:= true;
end;
function clickheretoplay: boolean;
var a, b: integer;
begin
if FindColor(a, b, 1647915, 214, 413, 563, 449) then
begin
result:= true;
mousebox( 214, 413, 563, 449, 1);
end;
end;
procedure LogMeIn(name, pass: string);
begin
wait(1000 + random(5000));
typesend(' ');//just hits enter, so it goes to the log in screen
wait(100 + random(2200));
typesend(name); //types your user name, and hits enter to go to the password
wait(200 + random(2201));
typesend(pass); //types password and hits enter so you log in
wait(1000 + random(2000)); //just a wait
end;
procedure LogIn;
var i : integer;
begin
if not AtWelcomeScreen then
begin
writeln('not at welcome screen yet');
repeat
wait(3000 + random(400));
inc(i);
until (i = 10 + random(3)) or Atwelcomescreen;
if i >= 10 then begin
writeln('Still not at Welcome Screen, exiting');
exit;
end;
end;
LogMeIn(UserName, Password);
while not clickheretoplay do wait(100 + random(100));
end;
begin
login;
end.now was that so hard? :)
Conclusion
that raps up my very firsrt scripting tutorial :D
post any feed back what so ever, even if you hate this tut, wish i would die in a fire, ect ect.
remember, stuff in this tut are only the BASICS of Simba and srl. there are HUNDREDS of different procedures, functions, and commands that you can utilize and learn.
If i get good enough feed back, i will think about making an other volume to this tut, that goes into more detail and more advanced stuff.
PM me on the forums or post here in this topic if you would like some help, or add me on msn: [email]akwardsaw@hotmail.com[/email]
Credits
First of all, i would like to thank the entire SRL community for helping out when i was a newby at scripting, and took the time to answer my countless and obvious questions :D
then, i would like to thank the people who wrote their awesome tuts, and made me learn even further about scripting.
the last "thank you" is for the srl members who voted no on my membership application a few months ago, you made me learn more about scripting and expect an uber script to come your way soon
Recommended Links
Unmatched beginers guide to scar This helped me out LOADS when i started to begin scripting, i recommend you read it too
How To Fix annoying scar errors. made by JAD, saved me LOADS of time and frustration, beileve me
Making your own includes pretty cool tut
~akwardsaw :norris: