After building objects of various shapes and sizes and playing around with the physics of SL which I found very interesting it was now time to start scripting.
I tried using the in-world tutorials but I eventually preferred using on-line resources through the web browser and ALT-TAB to the sim as necessary.
The "Hello World" Script
The next image shows part of a screenshot that shows the result of my first experiment, the typical "Hello World".

The wooden chair that I had created beforehand now has the simple script below behind it that will produce the message as shown above. The script is shown below :

Objects that send emails
After the above simple script I decided to try to make the chair sent an email when its touched besides saying something in the main channel.
I used the script below :
The script displays a message when the chair is touched and sends an email saying that it has been touched to my email address. Below is an image of the email I got from this exercise.

I also did some reading on the mailing functions of SL. I see that the system has in fact been used to send spam and that Linden Labs have taken steps to mitigate against this such as introducing a delay between emails. I doubt that spammers would really resort to using SL to send spam but then again you never know.
Objects that change when "touched"
I then spent a lot of time trying to make my chair change colour when touched. Although the actual script was not complicated, I kept having issues with the linking in the object and one of the legs was not being effected by the color change. This is the code I used :
The result was that the chair turned black on touch and then again to its original color when touched again as shows below :

A simple Notecard Giver
To build the Notecard giver I first created an cube and then stretched it so that it became a flat object. I also changed its texture from wood to a grey metal finish. The object is shown below :

As can be seen from the above image I also added an "llSetText" that displays the "Welcome Notecard" message.

The above image shows the script used for the notecard to be given. As you can see, while I was building and testing my Notecard Giver someone build a whole house around me. This is a problem I kept facing in the Fermi Sandbox because of the continuous activity going on there and many a time I had to move to a new location to avoid constantly being disturbed. For the script to work I of course also had to create a notecard in my inventory. Although I figured this out immediately, it took me quite a while to realize that the Notecard I had created had to be dragged into the "contents" of the object to be able to work. I kept getting an error that the notecard I selected called "My Notecard" was not part of my inventory.
Finally the next image shows that the notecard has been given to me and therefore that the script has succeeded.

Interacting with the WWW
It was fairly easy and required no scripting to display a webpage on a face of an object as can be seen below where my blog is displayed on the side of a stretched cube. The web page is displayed complete with scroll bars and can be used normally. It is also possible to disable the navigation controls and simply display a static version of the website. This exercise was simple because all I had to do was to simply drag the URL from my browser onto the desired object.

I tried using the in-world tutorials but I eventually preferred using on-line resources through the web browser and ALT-TAB to the sim as necessary.
The "Hello World" Script
The next image shows part of a screenshot that shows the result of my first experiment, the typical "Hello World".
The wooden chair that I had created beforehand now has the simple script below behind it that will produce the message as shown above. The script is shown below :
Objects that send emails
After the above simple script I decided to try to make the chair sent an email when its touched besides saying something in the main channel.
I used the script below :
The script displays a message when the chair is touched and sends an email saying that it has been touched to my email address. Below is an image of the email I got from this exercise.
I also did some reading on the mailing functions of SL. I see that the system has in fact been used to send spam and that Linden Labs have taken steps to mitigate against this such as introducing a delay between emails. I doubt that spammers would really resort to using SL to send spam but then again you never know.
Objects that change when "touched"
I then spent a lot of time trying to make my chair change colour when touched. Although the actual script was not complicated, I kept having issues with the linking in the object and one of the legs was not being effected by the color change. This is the code I used :
defaultThe original line for the example I worked on did not include "children" so I changed it to suit.
{
state_entry()
{
// sets all sides to most bright
//llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES);
llSetLinkColor(LINK_ALL_CHILDREN,<1.0, 1.0, 1.0>,ALL_SIDES);
}
touch_start(integer total_number)
{
state off;
}
}
state off
{
state_entry()
{
//llSetColor(<0.0, 0.0, 0.0>, ALL_SIDES); // sets all sides as dark as possible
llSetLinkColor(LINK_ALL_CHILDREN,<0.0, 0.0, 0.0>,ALL_SIDES);
}
touch_start(integer total_number)
{
state default;
}
}
The result was that the chair turned black on touch and then again to its original color when touched again as shows below :
A simple Notecard Giver
To build the Notecard giver I first created an cube and then stretched it so that it became a flat object. I also changed its texture from wood to a grey metal finish. The object is shown below :
As can be seen from the above image I also added an "llSetText" that displays the "Welcome Notecard" message.
The above image shows the script used for the notecard to be given. As you can see, while I was building and testing my Notecard Giver someone build a whole house around me. This is a problem I kept facing in the Fermi Sandbox because of the continuous activity going on there and many a time I had to move to a new location to avoid constantly being disturbed. For the script to work I of course also had to create a notecard in my inventory. Although I figured this out immediately, it took me quite a while to realize that the Notecard I had created had to be dragged into the "contents" of the object to be able to work. I kept getting an error that the notecard I selected called "My Notecard" was not part of my inventory.
Finally the next image shows that the notecard has been given to me and therefore that the script has succeeded.
Interacting with the WWW
It was fairly easy and required no scripting to display a webpage on a face of an object as can be seen below where my blog is displayed on the side of a stretched cube. The web page is displayed complete with scroll bars and can be used normally. It is also possible to disable the navigation controls and simply display a static version of the website. This exercise was simple because all I had to do was to simply drag the URL from my browser onto the desired object.

0 comments:
Post a Comment