Introduction
In this blog post we go into more detail in Second life and start building some objects in this virtual world. To start building in Second Life first you must go in a place in the world that allows the user to build. These places are called Sandboxes, it is only allowed to build in these Sandboxes and each Sandbox has its own rules such as you cannot build a wall around an avatar caging him being not able to get out without a teleport. Failure to abide these rules could result to a ban from Second life.
Building Objects
To Start building in the sandbox you right click the ground and select build from the menu shown this will make the building menu visible on the screen. Building is done by selecting shapes (prims) and placing them in the world. These shaped can be modified in shape, position and size as the user wants. Also multiple items can be linked together to form one object. This is done so that an Object will have more details to it and will look better.
The first object I created was a couple of boxes linked together to make a very bad looking chair that an avatar can sit on. Every avatar can sit on your object if you are not currently editing it. I made sure that when an avatar will sit on my object, it will sit properly.
Also you can create objects and wear them on your avatar carrying them around where you go showing, while showing them to other people. For this I decided to create a simple War hammer for my Avatar to carry around. I used the cylinder type prim and a cuboid type prim and linking them together after positioning them carefully at the right place.
To wear the object, just right click it and select wear from the menu. I decided to put the object I created on the right hand of my avatar. When I selected this the hammer didn't slot in my avatar's right hand correctly so I adjusted its position as well as I could to make it look like my avatar is carrying the hammer in its hand while walking.
To wear the object, just right click it and select wear from the menu. I decided to put the object I created on the right hand of my avatar. When I selected this the hammer didn't slot in my avatar's right hand correctly so I adjusted its position as well as I could to make it look like my avatar is carrying the hammer in its hand while walking.
Scripting
Users in 2nd life use Linden Scripting language to script objects and have them interact with the rest of the virtual world. To script an object, right click it and choose edit to open the edit window. In the edit window you may select "more>>>" to reveal five tabs marked general, object, features, content, and texture. Then choose "content". This window shows the contents of an object which can hold scripts, notecards, and even other objects. Press "new script" to add a new script.
When scripting an item you have to tell the object what to do and when will it do it. Simple examples of what an object can do with script include:
- Rez an object
- Give something to an avatar
- Say something in chat
- Change the object's color
- Change the object's texture
- Prompt an avatar to load a URL in a web browser
- Create hovering text
- Play a sound
- Move around
Amongst other situations these scripts could be performed in the following situations:
- As soon as the script starts
- When an avatar touches your object
- On a repeating timer
- When an avatar is nearby
- When someone says something
Here is an example of a script of an object changing its color to red whenever somebody touches the object the script:
default
{
touch_start(integer total_number) {
// change color!
llSetColor(<1.0,0,0>,ALL_SIDES);
}
}
This following example will have the object say "Hello" in the chat on every 30 seconds.
default
{
state_entry() {
llSetTimerEvent(30);
}
timer() {
// speak out loud!
llSay(0,"Hello");
}
}
After experimenting with these simple examples on the Hammer I created, I decided to create some more simple objects.
First I started with a very simple chair that would be used to sit on. I just used a cube to sit on and a thin cuboid to make the back of the chair, I combined both objects and made the avatar sit on it.
Finally as my last 2 scripts I decided to give a new script to my hammer to send emails and make it open an internet browser at a specific webpage.
The script used for the emails is as follows:
default
{
touch_start(integer total_number)
{
llEmail( "danielsammut92@gmail.com", "Test", "Test" );
}
}
And The script used to open a web browser to a webpage I desired is :
default
{
touch_start(integer total_number)
{
llLoadURL(llDetectedKey(0), "view my blog", "http://sammutdaniel.blogspot.com/");
}
}
Both scripts are run whenever the object is touched.
No comments:
Post a Comment