Introduction
Last week we started going into some Linden Scripting by doing some basic scripts this week we went in more detail and tried some more complex scripts.
First of I tried experimenting with a script that is found in the course material, where by clicking a prime your avatar can teleport.
Some of these functions where used to make the teleport successful. Vector DEST = <x,y,z>; was also used to select the coordinates to where I wanted to teleport the avatar to. I tried changing a bit these coordinates to see where my avatar will end. I also came along another new function begin changed_link this occurs when duplicating a linked object or when a prime in an object chages its types of shape. The event doesn’t happen when the object is attached or detached.
Strings
I started going into a lot of different worlds where I saw that they had some sort of writings on them showing. Therefore I tried doing it and I managed. First I declared a variable of type string and also what colour I was going to use. Deceleration was done as following: string message = "This is Cynthia's Prim";
Once those where declared I used llSetText(message, color, alpha);. This was quite an easy job. After this I passed to something more complex. You can display different text you can also display the description of the text by using llSetText(llGetObjectDesc(),<1,0,1>,1); or else displaying the object name using llSetText(llGetObjectName(),<1,1,0>,1); llGetObjectDesc and llGetObjectName will automatically get this information from the general section in the build panel.
E-mail
I started going into a lot of different worlds where I saw that they had some sort of writings on them showing. Therefore I tried doing it and I managed. First I declared a variable of type string and also what colour I was going to use. Deceleration was done as following: string message = "This is Cynthia's Prim";
Once those where declared I used llSetText(message, color, alpha);. This was quite an easy job. After this I passed to something more complex. You can display different text you can also display the description of the text by using llSetText(llGetObjectDesc(),<1,0,1>,1); or else displaying the object name using llSetText(llGetObjectName(),<1,1,0>,1); llGetObjectDesc and llGetObjectName will automatically get this information from the general section in the build panel.
| Another testing prime |
Next I built an object and made this object send e-mails. llEmail is a function used to send an e-mail you can attach the address, a subject and a message by first declaring them as: email (String time,string address,string subject,string message, integer num_left). This is triggered when a request by llGetNextEmail() is answered. Email’s time, sender’s address, subject, the message and number of emails queued are returned. Time is a Unix timestamp. The message can have a maximum of 1000 characters.
| Message format |
You can also remove the headers which are attached to the beginning of the message by making use of this line:
message = llDeleteSubString (message, 0, llSubStringindex(message,"\n\n")+1);
The object I created was a wall. I used different things things time instead of giving the object a colour I used textures and gave it a brick texture to make it seem like a real wall. Also I used the hallow which makes a kind of "whole" in the middle of the wall. Like this it makes it look like a wall with a window.
0. string email_address = "";
1.
2. default
3. {
4. state_entry()
5. {
6. llSay(0, "Hello, Avatar!");
7. }
8.
9. touch_start(integer total_number)
10. {
11. llSay(0, "I sent an Email");
12. llEmail( email_address, "Look it's an email 13.subject line!", "Testing 1 2 3" );
14. }
15. }
1.
2. default
3. {
4. state_entry()
5. {
6. llSay(0, "Hello, Avatar!");
7. }
8.
9. touch_start(integer total_number)
10. {
11. llSay(0, "I sent an Email");
12. llEmail( email_address, "Look it's an email 13.subject line!", "Testing 1 2 3" );
14. }
15. }
Above is the default code where I simply added the email_address variable on top and added the llEmail function. Which the subject is "Look it's an email subject line" and the message is "Testing 1,2,3". Below is a more complex example.
1. string email_address = "myemail@xyz.com";
2.
3. default
4. {
5. state_entry() {
6.
7.
8. llEmail( email_address, "Look it's an email 9.subject line!", "Testing 1 2 3" );
10. }
11.
12. touch_start( integer num_detected )
13. {
14. integer i = 0;
15. do
16. llEmail( email_address, "No touching!", 17. "My owner is: " + llDetectedName(i) + "\nKey: " + 18. (string) llDetectedKey(i) );
19. while(++i < num_detected);
20. }
21. }
2.
3. default
4. {
5. state_entry() {
6.
7.
8. llEmail( email_address, "Look it's an email 9.subject line!", "Testing 1 2 3" );
10. }
11.
12. touch_start( integer num_detected )
13. {
14. integer i = 0;
15. do
16. llEmail( email_address, "No touching!", 17. "My owner is: " + llDetectedName(i) + "\nKey: " + 18. (string) llDetectedKey(i) );
19. while(++i < num_detected);
20. }
21. }
Above is the code. First you start off by declaring a variable as a string which contains the e-mail address to which the e-mail is going to be sent, for the object while testing I used my personal e-mail address. In the state_entry, anything under the state_entry will be done every time the script starts running once unless you reset the script. Then it goes down and finds the first function in which this case is the llEmail. When it reads the function it reads the sting. In the touch_state, an e-mail will be sent showing by whom the object was touched. In the e-mail there will be details. llDetectedName will show by whom the object is created, while llDetectedKey gives you the key. Below are some screenshots of the received e-mail and also the message it contained.
| E-mail received |
This shows that the e-mail has arrived and is found in my inbox, junk section. Although at first I taught that it wasn't working properly since no e-mails where arriving in my inbox but then I found all the e-mails in the junk section.
Above is the e-mail message showing the details. The object name is defined by the creator who created the object inn the build section and can be anything. The region is where the object is found at the moment when the prim was touched to send the e-mail while the local position is the coordinates of where the object is found.
Conclusion
This week was another improvement towards Second Life, while working with prims and other building objects I continued touring around different worlds and continued getting more astonished as how many things can be done. Like waterfalls can be scripted and scripting the effect of a waterfall by setting a texture and rotating it will make it seem like water is flowing. Also at different worlds that there are. At first I can say that I really taught that SL wasn't that useful but getting to know it better I think it can be quite a success, being on your computer and chatting while sending gestures and doing as many things as possible can be quite a socializing event.
References:
http://lslwiki.net/lslwiki/wakka.php?wakka=llemail
No comments:
Post a Comment