Sunday, 29 May 2011

Week 12 - More second Life

Introduction

After the first lesson on second life which was a really interesting lesson we continued on more second life in much more detail. This week we spoke about building primes and also introduced LSL which stands for Linden Scripting Language, this type of scripting adds behavior to Second Life objects.

Right Click on the screen and select Build
During the lesson, we all went to Fermi Sandbox as a group. We walked as a group to a free space on the grass there we could notice that we attracted avatars to us since we were a large group avatars where probably finding it interesting. We continued getting comfortable with controls, gestures and teleporting after a while we started building objects. To build object you right click on the screen and select build. At this function a dialog box will pop up. On the right is the tools you need to build primes. On the top you select from, focus, move, edit,create and land. In the focus tab you can focus on where you want to create objects you can zoom in and out, orbit and pan. In the move tab you can grab the object and move it up and down spin it and also move it. Next is the edit tab in this section one can edit the object by stretching it, moving or rotating the object you can also give the object different colour. In the below screenshot I was experimenting with a shape and gave it a purple colour. You can either colour and stretch both sides or else only one side. 

Next tab is the create section here you can create several different shapes square, prism, pyramid, cylinder ring, tube, tree and grass. The trees and grass cannot be build everywhere. These two have to be created on land that you own.
The last tab is the land tab here you can do some transformation of the land first you select the area of the land that you want to transform then you can flatten it, raise it, smooth it, roughen it and then revert it. Then you have the bulldozer which will bulldoze any select area.
In the built panel there is also some other tabs which are;

  • General - In this section there one creator gives a description about the object being created like; giving it a name, description, who created it and also who can modify this object.
  • Object - The object section is from where you can change the dimensions of the object, you can also change the shape. 
  • Texture - The texture section is where you can give the shape different colours and textures set the transparency and glow
  • Content - The content is the section where you can add the LSL scripting. 
Creating Object
I started experimenting a bit first by building some shapes. I built a ring and edited and gave it some colours. First I started by creating the shape in the above case I used the ring. Then I went in object section and changed its dimensions, then I went to the textures section and changed its colours using the select a face so each face could be given a different colour which are purple and dark pink on the top.

LSL
After creating a shape I started by getting the hang of some LSL scripts. LSL is based on Java and C. A script in Second Life can be placed on an object but won't work on an avatar however these can be worn by avatars. To write LSL scripts one can find a built-in editor in the build panel under the content section. LSL has "States" and "Events". States are behaviours some examples are having a door which can open and close or a bulb which can light up or switch off. In a script there is at least a minimum of one script which is the default one. Events are predefined rather than being user defined. These can be caused in two ways either by objects and avatars interacting in the world or else they are created in a script. An example of an event is when an avatar touches an object  causes an event which is the touch_start ().

Below is a default script

1.  default
2.    {
3.       state_entry()
4.      {
5.           llSay(0, "Hello, Avatar!");
6.      }
7.      touch_start(integer total_number)
9.      {
10.        llSay(0, "Touched.");
11.    }
12.   }

The above code shows one state which is line 1. A state is defined by the word state followed by its name except for the default state and having the contents in 2 curly brackets  example: state running{}. Events are between the curly brackets of the state. When a state is active, events in that state are waiting to be triggered. Events are found on lines 3 and 7.  "state_entry" is triggered by the state being entered and "touch_start" when anyone touches the object.

More LSL


While working with SL
Next I tried getting on with some basic LSL. I created a new object a sphere. This script will change the objects colour when the avatar touches it. It has two states the default state and state off and has four events. The ball will be off a certain colour and when the avatar will touch it it will change colour. llSay will be display some text  on your screen. llSetColor will set the colour for the object. ALL_SIDES with a -1 value which will affect all sides of the prim.

1. default
2.   {
3.    state_entry()  
4.   {
5.       llSay(0,"Hello, Avatar");
6.       llSay(0, "Object is turning on!");
7.       llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES);
8.    }
9.     touch_start(integer total_number)
10.    {
11.       state off;
12.    }
13.   }
14.   state off
15.   {
16.    state_entry()
17.    {
18.      llSay(0, "turning off!");
19.      llSetColor(<2.0, 1.0, 0.0>, ALL_SIDES);
20.    }
21.     touch_start(integer total_number)
22.     {
23.       state default;
24.    }
25. }

ScreenShots of End Results




Moving an object. 
To move an object this is done with the use of coordinates. Usually we use x and y coordinates but since this is a 3D world there is also z coordinate. To move an object you need to use vectors. An object can be moved by stating the position to where you want to move it using llSetPos(<x,y,z>).To move the object north use a positive value while to move an object south use a negative value.

DeckChair.

I tried building some sort of deckchair and having the avatar to relax on it. To sit on this prime I used llSetSitText("Relax"); However till now this was not of success. I wanted the avatar to "lie down" as if he was really on a deckchair. The coordinates I was giving the script are the problem, as when I tried experimenting with them the avatar set far away on it. At the moment the avatar isn't lying down on the deckchair instead it is in a sitting position which has to be changed.  
Conclusion
Second Life keeps getting more and more interesting, during class hours we also took a snapshot of our group where we all went to middlesex in SL and sat around a fountain. After this blog we can see that scripts can be added to most primes in SL. I also think that when I used other languages I think I found more help, probably because this isn't used by the same number that other languages are being used. However as other languages to get to comfortable with it all it needs is practice. 






References:
http://wiki.secondlife.com/wiki/Help:Getting_started_with_LSL

No comments:

Post a Comment