Wednesday, 22 September 2010

Week 1: Second life scripting

Task 1: "Write a script that, when touched speaks your avatar's name and then counts to 10. It should use an integer variable for the count and a loop (for or while)."

I was introduced to Second life scripting for the first time, during the week I have learnt how the box intracts with the user in terms of scripting so that it gives the integer variable count from 1-10.

I have posted some screen shots below of my work:


Here i will show my coding which i have worked on for the box to interact with the user when touched.

default
{
    state_entry()
    {
        llSay(0, "Hello, Dover!");
    }

    touch_start(integer total_number)
    {
        integer counter = 1;
        llSay(0, "You have touched me, now I will count till 10");
        while (counter < 11)
        {
            llSay(0,(string)counter);
            counter ++;
        }
    }
}






Task 2: ''Write a script that keeps count of the number of times that it has been touched.''

Here in this task I managed to write a script where when the user touches the box, message returns with the value depending upon how many times the box has been touched.




 integer touch_count = 0;
default
{
    state_entry()
    {
        llSay(0, "Hello, Dover!");
    }

    touch_start(integer total_number)
    {
       touch_count ++;
       llSay(0, "Touched " + (string)touch_count + "time(s).");
     
    }
}

And the execution for this is:






Number of times the object has been touched with the count depending on how many clicks you give.

No comments:

Post a Comment