Second Life: "Teleport to Camera Position"

I wrote a script that, attached to a HUD object in Second Life, lets you teleport to the current camera position.

This is useful in combination with a couple of options in the Advanced menu (Ctrl-Option-D to enable):

Turn "Draw Distance" up to full in the Graphics preferences, and you'll be able to zoom the camera around the landscape easily. Once you've found a good location, this HUD script will teleport your avatar there.

I made a little screencast (no audio) with Istanbul to demostrate, but it's hard to see at this size. Here's an embedded video tag for Firefox 3.1 anyway:

or download the video file directly.

It looks like some existing HUD objects—MystiTool, DynaCam and HUD Warp—might also do this (and more). Here's the script:


// Teleport to Camera Location
//
// Instructions:
// Insert this script in a small prim.
// Attach the prim to any convenient HUD position.
// Touch the prim to teleport to the current camera location.  
default {     
    attach(key id) { 
        // If we're attaching, initialize
        if (id) { 
          llRequestPermissions(llGetOwner(), PERMISSION_ATTACH | PERMISSION_TRACK_CAMERA );
          llSetColor(,ALL_SIDES);
        } 
    }
    
    // Sort through required permissions.
    run_time_permissions(integer perm) { 
        if (perm & PERMISSION_ATTACH | PERMISSION_TRACK_CAMERA) { 
            llOwnerSay("Camera enabled.");
        }
        else {
            llOwnerSay("Camera refused.  Detaching.");
            llDetachFromAvatar();
        }
    }
    
    // Teleport!
    touch_start(integer total_number) {
        llSetColor(,ALL_SIDES);
        
        vector CamPos = llGetCameraPos();
        rotation CamRot = llGetCameraRot();
        vector CamFoc = CamPos + llRot2Fwd(CamRot);
        
        llOwnerSay("Teleporting to camera position on " + llGetRegionName() + ": " + (string) CamPos);
        llMapDestination(llGetRegionName(), CamPos, CamFoc);
        llSetColor(,ALL_SIDES);
    }
}