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:
No comments:
Post a Comment