Famous Scripts
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Scripts for RSBot made by Famous
 
HomePortalLatest imagesRegisterLog in
New scripts being created everyday! Go to GameKiller.net!

 

 Tutorial 1: Beginning Scripting

Go down 
+3
Kirus
jusbmx
Famous
7 posters
AuthorMessage
Famous
Administrator
Administrator
Famous


Posts : 50
Join date : 2009-10-23
Age : 29
Location : Chicago

Tutorial 1: Beginning Scripting Empty
PostSubject: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptyFri Oct 23, 2009 9:28 pm

Beginning programming may be hard for those with absolutely no
programming experience at all. To others, it isn't as hard because they
have had some experience with it. In this tutorial, I will teach you
the basics of programming. If you don't want to bother reading this
because you know about the basics already, then go on to tutorial 2.
It's always good to refresh your memory though Tutorial 1: Beginning Scripting Icon_e_wink Now onto the tutorial.

Tutorial 1: Beginning Scripting Icon_exclaim There are basically two things you should know about programming. You use these whenever you write a script.
Code:
1. Variables
2. Methods

First off, let's talk about variables. Variables are very important in
programming. Without them nothing will be able to function. A variable
in short holds information. This information can be displayed in many
different ways. One example is how many times you have hit something,
or collected something. So how do you use them you ask? First of all,
you have to declare them in your script. We'll get into that later in
this tutorial.

Tutorial 1: Beginning Scripting Icon_exclaim There are three main types of variables in programming.
Code:
1. Integers
2. Strings
3. Booleans

Integers are basically numbers. Keep in mind however, that you cannot use
decimals for integers, because there is another term for that. A
decimal is called a double. (We will get into this later). Anyways,
integers must be whole numbers. They can be negative though, so don't
worry. Remember though that integers do not have a set value. There
value can move around. An example of this would be if you start a
mining script. You probably have 0 ores mined when you begin the
script. But as time goes by, you may have 300 ores mined. The same
variable is used, but it just increased as we mined more ores.

So how do we declare integers?
Code:
1. You tell the computer what type it is.
2. You give it a name. (This name should be easy for other developers to
understand. Don't use lgschpd for an integer that declares how many
logs are cut. Try using something along the lines of logsChopped. It makes it a lot easier for other people to read and understand where you were coming from with the name).
3. You say "=" to show that you are setting the value.
4. You state the value. (Give it a number for int, or characters for String)

Here's a quick example to see if you understand so far.
Code:
int logsChopped = 0;
Let's break this down.

1. Int
What this basically means is that it is an integer. int = integer Tutorial 1: Beginning Scripting Icon_e_wink Pretty easy right? Integers hold whole numbers. They can't be negative, otherwise it's not an int.

2. logsChopped
This is the name of the integer. Keep in mind though that names are case sensitive, so be sure to be careful when your using these again, as it may give you an error if you spell it wrong.

3. =
This means that the int logsChopped equals

4. 0;
This is what the variable will equal. The semi colon is there because every
line of executable code will be followed by a semi colon to tell the
computer that the code is finished. (This will not apply to all types
of code).


This concludes the session on Integers.

Tutorial 1: Beginning Scripting Icon_exclaim Next I will be talking about Strings.
Strings are basically a string of letters or words. They are declared with quotations. These things: " "

Here's an example of a String.
Code:
String myUsername = "Famous";

That wasn't too hard, was it? Now lets move on to Booleans.

Booleans may be a little hard for you to grasp. I would suggest reading this
over carefully, and maybe even re-read it. Booleans are values that return
True or False. They are used to see whether your script still has money
left in your inventory, or if we need to walk back to the previous location that we were at because we died.

Here's an example of a Boolean.
Code:
boolean gettingAttacked = true;
All this is really saying is that if you are getting attacked, then return true. Now we will talk about how to use these 3 types of variables that you just learned about.

I'm going to give you some lines of code that use each of these variables
that you just learned about to give you an idea of how they are used. I
will try to keep this simple, so bare with me. Don't expect to just
jump right into programming, because it isn't that easy. Like anything, if you want to become good at something, you need to take your time and practice.
Integers
Code:
int miningLevel = 0;
int nextMiningLevel  = miningLevel + 1;

Strings
Code:
String name = "Famous";
String answer = "My name is " + name;
String sentence = "The dog barked.";
String question = "How good is your programming?";

Booleans
Code:
boolean attackMonster = true;
boolean eatFood = false;

Well hopefully you understood these examples, and are having fun learning in the process. Tutorial 1: Beginning Scripting Icon_e_biggrin

Now let's move onto methods.
Methods are fairly easy to write once you learn how to script. They are basically just describing how something is done.

Tutorial 1: Beginning Scripting Icon_exclaim There are two things you should know about Methods.
Code:
1. You have to write the method and tell it what to do.
2. You have to tell the computer where and when to use the Method.
So how do we write methods? Here are some (hopefully) simple instructions.
• You write the first line. This line contains the name of the method that will be called.
• You write the code inside the block, or in between the { }. These are used to tell
the computer where the method starts and where it stops.

To dive into writing methods, we'll use the infamous "Hello, World!" Here is what the base of the code will look like.

Code:
public void helloWorld {
log("Hello, World!");
}

Let's break this down.
Code:
1. Public
This just means whether or not other classes can use it or not. Don't worry about it to much, because I will explain it later.

2. Void
If you remember, all methods return a type of variable. When I put "void" there, that means it does not have to return anything, because it is void.

3. helloWorld
This is just the name of the method that is used.

4. log("Hello, World!");
This tells the script to display the message "Hello, World!"

To conclude, this is only the beginning into the world of programming. The
basics are the hardest, but when you get passed them, it gets much
easier. I promise Tutorial 1: Beginning Scripting Icon_e_wink So stick with it, and don't give up! Hope you enjoyed my tutorial, and please post your feedback!


Last edited by Famous on Sat Jun 19, 2010 3:46 pm; edited 2 times in total (Reason for editing : Updated)
Back to top Go down
https://famousscripts.forumotion.com
jusbmx




Posts : 1
Join date : 2010-03-13

Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptySat Mar 13, 2010 2:03 pm

ty! you save me 120$ on books Tutorial 1: Beginning Scripting Icon_biggrin
Back to top Go down
Kirus




Posts : 5
Join date : 2010-03-15

Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptyMon Mar 15, 2010 6:33 pm

Wow, thanks man, very helpful, good guide for beginners.
Back to top Go down
sh2head




Posts : 3
Join date : 2010-03-15

Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptyMon Mar 15, 2010 11:22 pm

LOL...ILKE IT !!!!!!!good guide for beginners !!!!
Back to top Go down
G3N3S1S

G3N3S1S


Posts : 5
Join date : 2010-04-19

Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptyMon Apr 19, 2010 2:35 am

Really good guide to the basics going to continue reading more of it =]
Back to top Go down
Legendary




Posts : 1
Join date : 2010-08-25

Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptyWed Aug 25, 2010 10:14 pm

I have one error with parsing at the end. not quite sure what to do. fixed the other 39 though Very Happy
Back to top Go down
Sanuka

Sanuka


Posts : 17
Join date : 2010-07-27
Age : 30
Location : Boskoop, the Netherlands

Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting EmptyFri Aug 27, 2010 10:22 am

Legendary wrote:
I have one error with parsing at the end. not quite sure what to do. fixed the other 39 though Very Happy
We might be able to help if you post your error and source code Surprised
Back to top Go down
Sponsored content





Tutorial 1: Beginning Scripting Empty
PostSubject: Re: Tutorial 1: Beginning Scripting   Tutorial 1: Beginning Scripting Empty

Back to top Go down
 
Tutorial 1: Beginning Scripting
Back to top 
Page 1 of 1
 Similar topics
-
» Tutorial 4: Banking
» Silk Buyer
» Tutorial 2: Writing your first script
» Pre Tutorial Methods
» Tutorial 3: Walking

Permissions in this forum:You cannot reply to topics in this forum
Famous Scripts :: Tutorials :: Tutorials :: Famous' Scripting Tutorials-
Jump to: