Wednesday, 30 November 2011

Week 2 - Touches, collisions and sensors.

This weeks tasks got a little bit more challenging compared to last weeks. But thats the whole point and its fun. We focused on collisions and sensors(scanning of objects or scripts). 


Task 1 was creating a script that upon touch, says avatar name and displays a message according to the time of day from England. The llGetGMTclock function was used, this returns the time past 00.00. This was then stored as an integer. Depending on the number of the integer, using if-else and nested if-else statements it was quite easy to work out the time of day.





For task 2 I had to create a script that would on collision with, say the name of the avatar or object and say the speed that it was travelling upon collision. It should also say the owner the of the object. This took a little bit of searching to get it down but in the end it worked! I used functions llVecMag and llDetectedVel to work out how fast the collision object was travelling. To work out the ownership of the avatar or object was done by llKey2Name and then llGetOwner. I must say I am starting to dislike scripting, but only because of all the mind-games it plays with me. Anyway, onward!





Task 3 was definitely the most difficult task for this weeks exercises. :( It was to create a script so that if touched, by the owner of the object, it scanned a 50m radius for avatars. But if it was not the owner of the object to only scan 25m. 


The difficult part was not checking to see if it was the owner that had clicked or not, that was easy. A simple If-else statement was put in. The difficult part was displaying all the avatars found in a reasonable way. The only way I could do this was to create a while loop that would go through each detected name and then print to screen.



Tuesday, 29 November 2011

Week 1 - Introduction to the LSL

In week 1, all we were doing were the very basics of scripting within Second Life. 

For the first task, I had to create a prim that could be interacted with upon touched. What the script had to do was display the avatars name once clicked and then count to 10. To do this I used the llDetectedName function and a do-while loop for the counter. Whilst browsing the LSL Tutorials, one page mentioned that a do-while loop is more efficient than a for or while loop. So here is me implementing that. 


I could show my code on here, but there is really no point for this exercise. 

For the second of this weeks tasks, which was actually a lot easier than I first thought it would be, was to create a script that keeps track of how many times it has been touched(clicked).

All I had to do for this task was add one line of code before the llSay function of the previous script and remove the loop. I also added the llSetText function so that it had hovering text above the prim. Here is it in action! 


I struggled with the second task a little bit because I was trying to over complicate things with for loops and what not! Then I realised this was only week one and I better go over it again. Im glad I did. >.>