Monday, 13 June 2011

Week 16 - Linden Scripting Language 3

This week was the last week where we talked on second life. We concluded this topic and discussed what we could to in the next weeks. In this post I'll be discussing three scripts that can be used in second life: teleporting, sending email and loading URL.

Teleporting

First, the target coordinates have been inserted, using a variable of type vector as shown in line 1. The llSetText() function shown in line 4 is used to display text on the object, where "Teleport" is the text displayed and <0,1,0> is the text colour (where in this case, it is green). The llGetRot() function will return the rotation of the avatar. The llSitTarget() function consists if a vector offset and rotation. In this case I did not want the avatar to sit down after teleporting; therefore the llUnSit() function shown in line 9 is used.
1:  vector target=<200,200,27>;  
2:  default{  
3:    state_entry(){  
4:      llSetText("Teleport",<0,1,0>,1);  
5:      llSetSitText("Teleport");  
6:      llSitTarget(target * (ZERO_ROTATION / llGetRot()),ZERO_ROTATION / llGetRot());  
7:    }  
8:  changed(integer change){  
9:    llUnSit(llAvatarOnSitTarget());  
10:    }  
11:  }  

Sending Email

The following script is used so that when the avatar touches the object, an email will be sent to me:
1:  string email_address = "vella.stevie@gmail.com";   
2:  default  
3:  {  
4:    state_entry() {  
5:      llEmail( email_address, "Second life", "Testing email" );  
6:    }  
7:    touch_start( integer num_detected ) {  
8:      integer i = 0;  
9:          do  
10:      llEmail( email_address, "Object Sender", llDetectedName(i) + "touched the object" + "\nKey: " + (string) llDetectedKey(i) );  
11:      while(++i < num_detected);  
12:    }  
13:  }  
In line 1, a variable of type string is declared, where the email address of the receiver will be typed, in this case, it is my email address. The llEmail() function, shown in line 5 consists of the email address, the subject and message. This will be sent to me and the subject is "Second life" and the message is "testing. This will be sent each time a new state is entered.
First Email
When the object is touched, another email will be sent, but this time in the message, it will show you who touched the object, using the llDetectedName() function and also returns the key of the object, using the llDetectedKey() function.
When Object is Touched

Loading URL

Another thing which you can do in second life is interacting with the web, using the llLoadURL() function when the avatar touches the object. When using this function a dialog will be shown to the avatar, in this case to load the web page http://stevie-89.blogspot.com, which is this blog with message "view stevie's blog".
1:  default  
2:  {  
3:    touch_start(integer total_number) {  
4:    llLoadURL(llDetectedKey(0), "view stevie's blog", "http://stevie-89.blogspot.com/");  
5:    }  
6:  }  
Loading URL

Conclusion

In the next weeks new topics will be introduced in class. These new topics will be HTML5, JavaScript, CSS3, mobile web development, facebook development, custom PHP libraries, cloud computing and web security.

No comments:

Post a Comment