Thursday, 30 September 2010

Week 2: Second life time and collision detection test

1. "Greet by a name with a Good Morning/Afternoon/Evening message (as every 4 hours depending on game what time) when you touch the object your script implies."

I was supposed to create an object with a script consisting of the time box letting the user know the time and following with a greeting message. I must say LSL wiki has always been useful in terms of using variable names. As for the second life I had figured that it consist of four hours per day accordingly making the program work with integers and attaching strings in order to create basic logical program.

Heres a screenshot to show what it indicates:












 


Heres the piece of coding which it involved to make the greeting and time:

default
{
    touch_start(integer total_number)
    {
        float tod = llGetTimeOfDay( );
        llOwnerSay("Time since last position or SL midnight):");
        integer hours = ((integer)tod / 3600) ;
        integer minutes = ((integer)tod / 60) - (hours * 60);
        llOwnerSay((string) hours+"h "+(string) minutes+"m");
        if (hours < 2 )
            llOwnerSay("Good Morning Dover!");
        else if (hours < 3 )
            llOwnerSay("Good Afternoon Dover!");
        else if (hours < 4 )
            llOwnerSay("Good Evening Dover!");
      
      
    }
}




















The screen shot of the user when touched the box it greets with the message:



















2.  'Write a script, such that when a collision by any oject or an avatar that collides with it says its name and also the speed at which the collider was travelling and the owner of the collider if it was an object'.


I tried to script the box and used the "llDetectedType" integer as '0' where the when the avatar or an object has been touched/collided, the box's message would appear as follows:




















Second test I couldn't find any help so I decided to do it myself with the help of moving or shooting object for eg. I had a default gun from free landmarks where you get freebies toys etc. I managed to try and test out the collision through it, noticed that it didn't affect or show any response. It was unsuccessfull :P




























This screenshot shows the gun which i tried to shoot the object(Pandora's Box) was unsuccessful.


So the code which I enherited into the script was:
default
{
    state_entry()
    {
    }
    collision_start(integer num_detected)
    {
        //detects collision with the avatar and prints name
        if (llDetectedType(0) & AGENT)
            {
                llSay(0,"I Collided with " + llDetectedName(0));
            }
        //detects collisions with an objects and prints name
        if (llDetectedType(0) & PASSIVE)
            {
                llSay(0,"I Collided with " + llDetectedName(0));
            }
    }
}



And Here is the screenshot of the script:















Week 2: To make the object(Pandora's Box) detect avatars(Agents) within a certain radius.

Using a for loop starting at 0, i.e. the first index of the detected agent array, I gave some output based on that index. And execution:

With a greeting message.


















Only by clicking the object again the search takes place, as they were no one in the sandbox i managed to find myself.  :p

Here the screenshot of the code and execution:


default
{
    state_entry()
    {
        llOwnerSay("Hello, Avatar! How are you today?");
    }

    touch_start(integer total_number)
    {
        llSay(0, " Please Wait Searching for agents");
        //searches for avatars and gets the owner names
        if (llDetectedOwner(0) == llGetOwner())
        {
            //executes if owner is touching
            llSensor("", NULL_KEY, AGENT, 50, PI);
        }
        else
        {
            //executes if another avatar is touching
            llSensor("", NULL_KEY, AGENT, 25, PI);
        }
      
    }
  
    sensor(integer total_number)
    {   //number of owners tracked in the search radius
        llSay(0, (string)total_number + " agents in search radius");
        integer i;
        for (i = 0; i < total_number; i++)
        {   //outputs the results of no.of avatars detected
            llSay(0, "You've been detected, " + llDetectedName(i));
        }
    }
}

Wednesday, 29 September 2010

Week 2: Idea for the assignment

Dover's Rifle Range or Wild west shooting range

This is based on a 'Victorian' shooting range in common fairgrounds in real. The game is played with a gun and number of different targets, shooting the balls out of the clowns faces, shoot the sweets or cans from the shelf, or a real personal touch to knock over targets, these can range from something like a pirate themed event. Probably set up a prize as a card recieve to the player for the rank depending upon the level and accuracy of the target hit.



I was thinking of a theme such as 'Wild West Game Stalls' Utilising the same technique and scripting with a bit of sound effects if its possible to acheieve from the second life, so that playing a mixture of sound effects and themed music all helping to evoke the Wild West image. In addition to graphics I could also add some horshoes toss, cactus hoopla, shoot the indians or shoot the cavalry. I could also source various items such as cowboy hats and toy guns to allow the players to join in with the fun to play the stall with keen interest for a stunning themed event. Things could be added like inflatable cactus or life sized cut outs of 'John Wayne and Rowdy Yates'.


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.