Sunday, August 27, 2017

Make a Postcard in Second Life

Hello, readers!  Today's post is a How To.

Let's say you've just visited an astoundingly beautiful place in Second Life, and you want to tell your friends about it.  You could, of course, just send them an IM.  Open your Map, click "Copy SLURL to Clipboard" and then hit CTRL+V to paste the location in your IM window.

But you have more class than that, right?  Let's send them a postcard instead!

First, you'll need to take a picture for your postcard.  Here I am at the Iron Cloud sky platform in Caledon:

I saved this picture to my hard drive (one of the options in the Snapshot window).  Then in Photoshop, I added some text.

While I was at the Iron Cloud, I also used World/Create Landmark Here to make a landmark.  Then I right clicked the landmark and selected "Copy SLURL" to put the location information on my clipboard.  I pasted that into my Photoshop image as text.  But later, when we get our postcard back into SL, we can do better than that...I'll show you how to make your postcard offer the recipient the landmark.

Anyway, here's our postcard image:
Before we upload it to Second Life, we need to re-size it.  SL prefers images that have pixel dimensions that are a power of 2...for example, 512 x 512.  Also, you can't upload textures that are larger than 1024 x 1024 pixels.  So we'll re-size this image to 512 x 512.  It will make it look squished horizontally, but that's OK.  We'll fix it later.

Here's what we'll upload:

Next, we rez a prim, and change its dimensions so that it resembles a 4x3 postcard...but we'll make it a bit bigger, 0.02m x 2m x 1.5m.  Then we'll change the texture to Blank, for a white postcard, and also set the texture to Full Bright.
Then we apply the texture we uploaded to one face of the prim.  It will be stretched back to its original 4x3 aspect ratio, if we set the texture repeats in both dimensions to 1.0.
In the General tab of the Edit window, let's rename it.  I called mine IronCloudPostcard.

Now let's add some things.  Drag the landmark for Iron Cloud and drop it into the Content tab of the Edit window.  Then let's write a notecard describing the wonders we saw on our visit.  Right click in your Inventory window, select New Note.  Give it a unique name, so you don't have a few hundred "New Notes" floating around in your inventory.  Type your text, save the note, and drag and drop it into the Content tab along with the landmark we put there previously.
Finally, we need a script that will give the card's contents to its owner.  The script below is one such, and will give the contents of the prim to the owner when the prim is clicked.

// This script will automatically give the contents of the box (except this script)
// to the owner of the box when the box is touched.  The contents will be given in a
// folder with the same name as the box. The box can be set to prompt the owner to delete
// the box.
// Created by Digi Vox for OnRez, 2007, donated to public domain

list get_items() {
    string      this_script = llGetScriptName();
    string      name;
    integer     max = llGetInventoryNumber(INVENTORY_ALL);
    integer     i;
    list items = [];
    for (i = 0; i < max; ++i) {
        name = llGetInventoryName(INVENTORY_ALL, i);
        if(llGetInventoryPermMask(name, MASK_NEXT) & PERM_COPY && name != this_script) {
            items += [name];
    return items;

default {
    on_rez(integer n) {
    state_entry() {
        llSetText("Touch me for more information", <1.0, 1.0, 1.0>, 1.0);
    touch_start(integer n) {
        if (llDetectedKey(0) != llGetOwner()) return;
        llGiveInventoryList(llGetOwner(), llGetObjectName(), get_items());
        //llSetText("This box has been unpacked.\nYou can delete it now.\n(Right-click->Delete)", <1.0, 1.0, 1.0>, 1.0);

Copy the above text, right click in your inventory and choose New Script.  Paste the text into the script window and save it.  Then drag the script into the content tab of the postcard.
We're done!  Right click the postcard and Take it into your inventory.  Now just open a friend's Profile and drag and drop the postcard onto their profile picture to send it.

That's a lot of work just for a postcard!  Most people in SL limit projects like this to special occasions, like wedding announcements or Christmas cards.  But these steps are also what you'd do to create a box for a product and load the box with the these techniques are quite useful, even if you don't use them for postcards!