Difference between revisions of "User:ANSI Soderstrom/LSL Beginners Class"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 31: Line 31:


<lsl>
<lsl>
// a integer is ever a number. This number can have a value from −2,147,483,648 up to +2,147,483,647. This is enough for the most cases.
// a integer is ever a entirety number. This number can have a value from −2,147,483,648 up to +2,147,483,647. This is enough for the most cases.
// if you want to work with a number, think about a UNIQUE identifier and mark this identifier as "integer"
// if you want to work with a number, think about a UNIQUE identifier and mark this identifier as "integer"
integer myNumber;
 
// variable declaration
integer myFirstNumber;
 
// variable declaration with initialisation (preferred)
integer mySecondNumber = 0;
 
// to work with decimals, declare your identifier with "float"
float myThirdNumber = 0.2;

Revision as of 03:48, 24 April 2011

Hi and welcome to my LSL Beginners Class.

First, we need to know how the computers can understand the Humans. Don´t forget that computers are very dumb if we don´t tell them how to work and above all : what is what !

So, let us begin with How to use comments. Comments are very important to let know yourself what´s where exactly happened. If you read your code in a half year again, then it´s sometimes very hard to understand the idea behind your own code. Believe me :)

Our LSL-Examples are ever in grey boxes (like the grey box below this line), also you can copy/paste this code directly to your LSL-Editor.

<lsl> // the well-known comments are always starting with a double-slash. The LSL-Editor will display comments in a orange color. // A comment with a double-slash ends automatically at the next line break. i'm not a comment (because the missing double slash) and i will produce a error at compiling this code

/* To comment (or comment out) multiple lines you can use a slash with a following asterisk. If you are done with your multiple-line comments, just write a asterisk again, followed from a slash All sentences between this slash->astersisk combinations are comments !

  • /

// you can mix this comments in this way too :

/* COMMENTS ARE NEVER INTERPRATED BY ANY COMPILER AND USING NO MEMORY // so it´s a good choice to write so many comments as you can // you write the comments for YOURSELF (except you plan to sell your code) // If you want to sell your code, use comments !!! comment your code !!! ever !!! always !!!

  • /

</lsl>

Now we need to know how to tell our objects how to work with numbers, strings, vectors and so on. In LSL (and in all other languages too) there are different [Types] we can use :

<lsl> // a integer is ever a entirety number. This number can have a value from −2,147,483,648 up to +2,147,483,647. This is enough for the most cases. // if you want to work with a number, think about a UNIQUE identifier and mark this identifier as "integer"

// variable declaration integer myFirstNumber;

// variable declaration with initialisation (preferred) integer mySecondNumber = 0;

// to work with decimals, declare your identifier with "float" float myThirdNumber = 0.2;