Friday, March 12, 2010

Second Life - March Madness Entry 12

Some people shudder at the mere thought of it - others salivate at the mere potential of an essentially open world with open scripting and building tools. That's right, I'm talking about Second Life.

I fall somewhere in both camps. I was essentially graded on my immersion of it back in college during my Junior year, where I had to complete an "art project" for a Professor. The project required I write a number of scripts and help generate a lot of interactive content. I got the project done, but was so tired of the public areas of Second Life and the overall depressing reminder of what kind of humanity visits such a place.

It being a lonnnnnnnnnnng time since I've done anything in Second Life, I've managed to forget most of the LSL scripting language. With one of my fellow hackerspace members in charge of virtualizing NJ's state college of Rutgers into the Second Life world, I could hardly not check out the campus and give it a look-see. Heck - the above screen shot is taken in the campus's virtual stadium. Here's a quick hello world that changes a boxes color to red.



First, find an area where you can actually create an object. You can't edit/create objects just anywhere. Once you do, right click it and hit "Edit". In the properties box, select Content and hit New Script.
default
{
    state_entry()
    {
        llSay(0, "Hello, World!");
        llSay(0, "This is a sample color changing block script. Nothing special.");
    }

    touch_start(integer total_number)
    {
        llSay(0, "Changing color...");
        llSetColor(<1, 0, 0> , ALL_SIDES);
    }
}

This is a pretty basic program. From what I remember, an object can have multiple states, which are similar to classes for these objects. default is, obviously, the default state when the object is created.

state_entry() is what's executed when the program first begins - my object just welcomes the world and informs them of its worldly task.

touch_start() is the amount of times the object is touched. I can't remember at all what integer total_number is - sorry. As soon as my object is touched, it forces the color to change to red.

And that's it.

No comments:

Post a Comment