Wednesday, 8 December 2010

Second Life Physics, crazy stuff!

Well got the teacup, have the code and it sort of works.....

The teacup acts pretty weirdly with impulse, its not always going in the right direction and there is one other quite interesting effect which complicates matters, the teacup will spinn off wildly in any direction if it hits anything thats in the way and at the moment the sky above the island seems to be a little full of objects, building and other miscelaneous things. Its added a little bit of extra added fun and there is now no way i judge where or what side up the teacup will be when it finishes its cycle of movements.

This was fully shown at the demonstration when i found the teacup and myself spinning out of control inside a building, fun but not what i was originally hoping for. The way it all works is odd and not quite what i was expecting from the initial code. Great fun but frustrating! 

Saturday, 4 December 2010

Project horrors and changes

The firefly was nice to look at but totally useless for my needs, 'no copy, no modify' - wasnt able to do a single thing to the vehicle to get it doing more than just sitting there. An utter disaster and a waste of a couple of weeks searching. Back to square 1, decided to try the rollercoaster idea.

The teacup is born, well an aproximation of a teacup exists im not that great at building things with the interface that second life uses, but its here and its well colourful:





By using and extending the code from the flying saucer boomerang ive created and reasonably random off rails rollercoaster that can be used anywhere as it has no physical points to go too. Slight problem with early attempts - the teacup seems to defy gravity every now and then and ive managed to loose 6 copies of version 2 because the have just drifted up into the air as soon as ive pulled them from my inventory, its just plain weird!!

Tuesday, 30 November 2010

Project changes and helpful vehicles

Weeks 7 and 8 were given over to pretty much searching the LSL marketplace for a suitable vehicle to use for the project, some success in getting the vehicle for the flight simulator, someone has made a firefly and on the market place its entirely free - result!


Isnt she beautiful, hopefully this lovely craft will help me create a okayish flight sim with some good vehicle code and some randomly moving targets should be fun.

Monday, 22 November 2010

Heads up!!! Its HUDs!

HUDs are extremely useful and i was amazed at how simple it was to create custome HUD's the idea of just creating prim and put an image of what you want onto it, the idea is so simple its almost beautiful and probably the best thing second life does.






The above picture shows the prim with the fire text atachted to the HUD the prim acts like a button which fires my weird flying saucer as a bullet.

Project - On the search for a vehicle to use in the flight sim, still think that the off rails rollercoaster might be the better option.

Sunday, 14 November 2010

Project Design and List taking

Well week 5 and we are ... making lists, lists everyone needs lists and it can be suprising what you can do with a good list. For the example exercise we were tasked to create a prim which would record the number of objects and avatars which have bumped into it. Shown below is the code for this prim making the lists:

list mylist = [];

default
{

state_entry()
{
// llSay(0, "Hello, Avatar!");

}

collision_start(integer total_number)
{

llOwnerSay(llDetectedName(0) +"::"+ (string)llVecMag(llDetectedVel(0)));
string name = llDetectedName(0);
float vel = llVecMag(llDetectedVel(0));
mylist = [name, vel] + mylist;

}

touch_start(integer total_number)
{
llOwnerSay((string) mylist);
}
}

Project Design - now a little bit serious, my project has a few ideas in fruition it will be either a flight sim or an off rails rollercoaster. Using the impulse and gravity commands to navigate them, should be lots of fun to create and play about with.

Monday, 8 November 2010

guns, flying saucers and other miscelaneous terror!

Seriously falling behind here, useless at blogging heres weeks 3 and 4.

Week 3 Ressing objects - this was alot of fun and relatively simple to do once i got the hang of the gun mechanics, the barn door was pretty simple and the code is pretty straight forward:

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

    collision_start(integer total_number)
    {
        llOwnerSay(llDetectedName(0) +"::"+ (string)llVecMag(llDetectedVel(0)));
        llOwnerSay(llKey2Name(llDetectedOwner(0)));
        //llOwnerSay(llDetectedName(0) +"::"+ (string)(llDetectedVel(0)));
    }
}

 Week 4 was much more interesting and dealt with the movement of objects i enjoyed this lecture alot and played about with the physics of gravity in second life to create a flying saucer and creating some simple movement commands to send the ufo flying away from me for a few seconds, stop then fly back. Here is the code:
default
{
  
    touch_start(integer total_number)
    {
        llOwnerSay("Touched. Starting Flight");
           float mass = llGetMass(); // mass of this object
           float gravity = 9.8; // gravity constant
        llSetForce(mass * <0,0,gravity>, FALSE); // in global orientation;
       
        llApplyImpulse(llGetMass()*<0,5,0>,FALSE);
        state time;
      
    }
   
   
}
    
state time
    {
    state_entry()
        {
            llSetTimerEvent(5);
        }
   
     timer()
        {  
            llApplyImpulse(llGetMass()*<0,-10,0>,FALSE);
            state time2;
        }  
               
    }
   
state time2
    {
    state_entry()
        {
            llSetTimerEvent(5);
        }
     timer()
        {
            llApplyImpulse(-llGetMass()*llGetVel(),FALSE);
            state default;
        }
    } 

By using impulse i get a steady movement which can sometimes go a little crazy when it hits something but here are some images of the heart of gold (brown taurus!) in action:







Pictures of a moving object dont work very well but its there and it works wonderfully :D

Project
For the amusement park im going to use the movement physics to to create a simple flight sim which will enable the players avatar to get into an aircraft and fly through a series of moving targets in a specific time limit. The user will gain points for each target they fly through and this will be posted with the times of other players in notecard form. The vehicle will use the inbuilt vehicle commands and the targets will use timed impulse movements such as the one used in the above flying saucer.

Tuesday, 5 October 2010

Second week of scripting in lsl - annoying language.

Now im gettting to grips with the language, its relatively simple (compared to c++) but can be very annoying when the syntax goes wrong, For this week so far i have only attempted two of the exercises so far, still trying to find some time around other areas of my time to get to that and the blogging - not good at the moment.

The first example of script that was needed was an object which told the time and said whether it was morning, afternoon or evening to the avatar, as the second life day is only four hours this would happen quite often! :D

I chose a cylinder for this object, purely for a difference. Below is the script working in Second Life:

The code for this is shown below:
default
{
    touch_start(integer total_number)
    {
        float tod = llGetTimeOfDay( );
        llOwnerSay("Time since last region restart or SL midnight (based on SL 4 hour day):");
        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");
        else if (hours < 3 )
            llOwnerSay("Good Afternoon");
        else if (hours < 4 )
            llOwnerSay("Good Evening");
       
       
    }
}

The other of the two tasks that i have finished is a collision detection model which tells me who has colided with the object and how fast they were moving. The script was pretty easy to find and worked pretty well. Below is the script in Second Life:

And below is the script for this object:
default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    collision_start(integer total_number)
    {
        llOwnerSay(llDetectedName(0) +" has collided with me!");
        llOwnerSay(llDetectedName(0) +" was traveling at: "+(string)llVecMag (llDetectedVel(0))+"m/s");
    }
}
It converts the speed into metres per second which is easier than mph or another measurement. Will be interesting to see what we do in week 3, and maybe i will get a blog out on time, you never know it might happen!