- Second Life Business Magazine: Issue 2: Making Money with Music.
- Alex Bosworth: How to Provide a Web API – “In a world where people are making interdependent webservices, API design and maintenance is pretty important. “
- Nat Torkington: How to Roll Out an Open API – “If you want me to use this API, you’d better start thinking about it from my side: I want something that’s easy to start using and that will scale with the coolness of the apps I build.“
- People Kill People – “The FAA, which has in the past banned such objects as toenail clippers and hair gel, took the extraordinary step of banning people after the Department of Homeland Security conducted a thorough investigation of previous terror plots.“
Monthly Archives: August 2006
I Willed This Site Into Existence!
Ok, this is pretty funny…
After become a regular in Second Life, I thought it would be cool to have a Digg-like site focused on stories that revolved around Second Life. I checked and found that someone had registered sligg.com, clearly the most natural name for such a site. At the time I checked, there was no content at the site. I threw the URL into Watch That Page and forgot about it.
Today I got my daily update email from Watch That Page, and it showed me that there had been a change at Sligg! I paid it a visit, and — sure enough — the Digg-like site that I wanted was there!
Of course I registed and then submitted my Elevator Script to the site.
The site has an RSS feed and I look forward to visiting and submitting new information to it on a regular basis.
Links for Sunday, August 27, 2006
- Gutsy Web 2.0 Development Team For-Hire, Cheap! – “A year from now, they will be one of the hottest tech companies in Utah. Right now, they’re looking to keep food on the table, and the bill-collectors at a reasonable distance… and keep their dreams alive.“
Links for Sunday, August 20, 2006
- Proceedings of the Education Workshop at the Second Life Community Convention – “This abbreviated printing of the proceedings is for conference attendees and particularly interested community members.“
- TDavid: 49 Ways to Crack Writer’s Block – “3. Write about the last nightmare you remember having.“
- NMC Campus Teacher’s Buzz Sessions – “As part of our effort to create some regularly scheduled events on NMC Campus, we are aiming to launch an informal meetup specifically for teachers already teaching in Second Life, or those who wish to learn from the brave pioneers.“
- Mitch Kapor on the Power of Second Life – “There was $40,000 raised for the American Cancer Society in Second Life. At first I thought, well, that was a one-time thing, but now I’m thinking, No, if you have a real-world organization then you want to have a presence there.“
Second Life Scripting – The Elevator Script
One of the most important aspects of Second Life is the fact that every prim (building block object) can contain executable code — script — which can control the appearance and behavior of the prim, communicate with avatars and with other prim, respond to events, and so forth. The scripting language is called LSL (Linden Scripting Language) and is documented in the LSL Wiki.
In this post I am going to document a script that I call the “Elevator Script.” I built this script as part of an ongoing series of experiments that I’m conducting into presentation styles within Second Life. I assume that you have some familiarity with a modern scripting language like Perl or PHP. I won’t be spending any time discussing language syntax or fundamentals.
I used GraphicsEx to take a tall picture of the Amazon Web Services Blog. I used The Gimp to scale the down so that it was exactly 512 pixels wide. Next I created a series of square images, each 512 by 512 pixels in size. I uploaded the images to Second Life, and created a tall stack of square prims. I then textured each prim with the appropriate blog image; the result was a tall image of the entire blog, as you can see at the right.
The script runs inside of a chair prim — a simple grey square which you can see at the base of the blog to the right. When an avatar sits on the chair, the script is activated. The chair rises, step by step, until it reaches the top of the blog, then it reverses course. When it gets to the bottom, it instructs the avatar to stand up, and it remains at rest until another avatar sits down.
LSL includes a unique state-machine model which can simplify and clarify otherwise complex scripts. The Elevator Script has four states:
- default – Every LSL script starts out in the default state.
- idle – The chair is in this state when it is waiting for an avatar to sit on it.
- going_up – The chair is in this state when it is ascending.
- going_down – The chair is in this state when it is descending.
Here’s an outline of the script. LSL makes it easy to model states, by enclosing the code for each state in a distinct block like this:
state idle { }
state going_up { }
state going_down { }
We’ll start with a couple of definitions:
These values simply set the minimum and maximum height (in meters) of the chair with respect to the ground. Before I go any further I should note that you need to be extremely careful when writing scripts that have the ability to move prims. If you write a script that moves the prim up by one meter every second, it will happily move up, up and away. If you can’t catch it and stop the script, you have effectively lost the object! Second Life is a take no prisoners, real time world — there’s no undo, and once that object is out of sight you are going to have a really hard time finding it again. Trust me on this one!
Next up is a simple function to set the prim’s text label. The given string floats above the prim. In the code below, the value “<0, 1, 0>” is an RGB color vector. This value says that I want no red, full green, and no blue. The third parameter, 1.0, specifies that the text should not have any transparency.
The implementation of the default state is pretty simple:
The state_entry is like a special form of function declaration. It says that the code inside is to be run each time the state is entered. llSitTarget fine-tunes the seating properties of the chair so that the avatar appears to be resting immediately on top of the chair rather than “in” the chair. llSetTimerEvent arranges for the timer handler in the current state (whatever it happens to be) to be run every 2 seconds. Finally, the state is changed to the idle state.
Here’s the code for the idle state:
vector pos = llGetPos();
float GroundHeight = llGround(<0, 0, 0>);
pos.z = GroundHeight + MIN_HEIGHT;
llSetPos(pos);
}
changed(integer Change)
{
if (Change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
Text("Welcome aboard!");
llSleep(3);
state going_up;
}
}
}
}
The state_entry code is run when the state is set to idle. The first call is to the Text function, to display an instructional message above the chair. llGetPos is used to get the chair’s current position, and llGround is used to get the height of the ground immediately beneath the chair. MIN_HEIGHT is added to this value, and the chair’s height (z) is set. In effect this code leaves the chair’s x and y position unchanged and sets the chair’s height to be 2 meters above the ground.
The changed code is run when an avatar sits on the chair. The call to llAvatarOnSitTarget ensures that there’s really an avatar sitting on the chair. Assuming that this is true, the message is changed to “Welcome aboard!” and the script pauses for 3 seconds. The state is then set to going_up.
Oh yeah, one last thing. Remember that timer we set in the idle state? It is going off every 2 seconds, but since there’s no timer function in the idle state, nothing happens. A more sophisticated script could (and probably should) use the timer only while the elevator is actually moving.
Here’s the code for the going_up state:
Entering the state is really simple — change the message and that’s it.
Now, back to that timer. The chair wants to move now, so each time the timer event comes in, the event handler gets the old position, adds the vector value <0, 0, 2> (move up 2 meters) to the position, and then checks to see if the maximum height has been reached. If the height has not been reached, the new position is set using llSetPos. If the maximum height has been reached, the state is set to going_down, and on the next tick of the timer the event handler in the going_down state will be activated.
The handler for the changed event detects the departure of the avatar. If the avatar stands up while the chair is in motion, the text label is changed, and after a short pause the chair returns to the idle state.
The code for the going_down state is similar:
There’s one important difference — when the chair reaches the lower extreme of its motion, it unceremoniously boots the avatar off of the chair (they will return to the standing position) using llUnsit and enters the idle state.
Ok, does this make any sense? I hope that you can see how the states in the script effectively mirror the actual states of the elevator. LSL is really pretty easy to use, and because it it has the ability to control and to move prims, the scripts can generate interesting effects with just a modicum of code.
One more thing — if you want to see the elevator in action, hop on over to Athabasca. Walk through the building and go up to the third floor, and you’ll see the elevator. Let me know what you think!
My Travel Kit
Without really meaning to, I have accumulated a fairly large kit of stuff that goes along with me when I travel. In order to make sure that I don’t lose anything I bought some mesh bags to keep it all in once place. Here’s what I have:
From left to right, row by row:
- Battery charger for Samsung Digimax L60 Camera
- Miniature mouse
- USB cable for camera
- AC adapters for Blackberry
- Digital Multimeter
- Utility Knife
- USB Flash Drives
- iPod cable
- Blackberry charger
- LED flashlight
- AC adapters for laptop
- AA battery
- Imitation Leatherman tool
- Drinking straw (not sure why I have this, but I do)
- Headphone / microphone, for Skyping
- Flat Ethernet cable
- Sewing kit
- Flat and Phillips screwdrivers
- Laser pointer and spare pens
- Folding hair brush
This weighs 4 or 5 pounds and I just toss it into my suitcase (which I always check).
Links for Saturday, August 19, 2006
- Holger Bast, Ingmar Weber: Type Less, Find More – “Fast autocompletion search with a Succinct Index.“
- The Phoenix: Right-Click to Learn – “For those accustomed to traditional forms of online learning, the possibilities presented by a 3-D teaching environment make correspondence courses seem antiquated.“
- Sarah Robbins: Image Slippage – “Navigating the Dichotomies of an Academic Identity in a Non-academic Virtual World.” The target content is in a Word doc linked from the image!
- Tristan Louis: Top 10 Opportunities in Virtual Worlds – “I would generally group the opportunities for virtual world vendors into three broad category: access, hosting, and tools.“
- Feed Crier – “News alerts to your instant messenger.“
Random Day
I’m taking a vacation day today, which means that I’m sitting in front of the computer doing all sorts of random stuff. I’ve accumulated 4 weeks of vacation time and I need to burn some because I am at the limit.
So far I’ve:
- Upgraded this blog to WordPress 2.0.4.
- Posted my son’s latest emails to his missionary blog.
- Upgraded to the latest version of Thunderbird.
- Replied to over 25 emails and filed or deleted another 60. I’m not yet ready to declare email bankruptcy, but the thought is certainly tempting.
- Found out that my Dell battery is a fire hazard and will have to be replaced.
I’ve also got to do some real world stuff, make some phone calls, and I want to build some new stuff in Second Life today too.
My Optimus Mini Three is Coming Soon
In fifth grade (let’s say 1972 or so) I was assigned to write my Geography report on Russia. At that time, Russia was the other superpower, dark, mysterious, and half a globe away. Now I buy things from Russian vendors via the web on a regular basis, exchange email with native Russians who write in excellent English, and so forth. Today I got word that my Optimus Mini Three will be shipped from Russia on August 30th. I’m still not sure what I’ll use it for, but I’m sure I’ll come up with something.
Links for Thursday, August 17, 2006
- RFC 4627: JSON – “The application/json Media Type for JavaScript Object Notation“
- Adam Howlitt: How to Design a Large Ajax Application – “In the guide which you can download from the link below I’ll cover the process I have developed in the course of implementing two AJAX applications…“
- Bruce Schneier: Last Week’s Terrorism Threats – “Last week’s arrests demonstrate how real security doesn’t focus on possible terrorist tactics, but on the terrorists themselves.” There’s lots of good discussion and info in the comments to this post.
- John Rogers: Wait, Aren’t You Scared? – “Who the hell am I supposed to be scared of? “
- Just One Club Card – “Put all of your club cards onto just one card.“
- Speedtest.net – “Speedtest.net is a general use broadband connection testing site with many geographically dispersed servers to test against.“
- Figments & Co: Great Builds of SL: Volume 1: Architecture – “We are excited to announce the release of our first in-world book, freely available at Figments land in Bisque.“
- Rezzust: – “Virtual Content Creators, SecondLife Development and Virtual Architecture“