Table of Contents

About

This is a simple leash script that will attach from the primitive that the script is in to an object. Once attached to an avatar, the script scans the local area for a certain object name (NAME_OF_OBJECT) and, if found, it checks whether the owner of that object is you. If you are the owner of that object, then the script will generate particles to simulate a leash.

The script was originally created for Mandy Deed and meant as a leash to her pet. This script was placed in a leash loop and then attached to her hand. The script scanned the vicinity for her pet, named Persian_1 and generated particles simulating a leash.

This script will leash one object to another on script reset, provided that the owner of both objects is the same. It is also unable to leash objects to one-another if they are worn attachments. For a more elaborate script that will re-leash attached objects, please see the horse martingales script or the cuffs script.

Setup

Code

basic_leash.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
//                   CONFIGURATION                      //
//////////////////////////////////////////////////////////
 
// Change this to the name of the object that the leash
// should attach to.
string NAME_OF_OBJECT = "Persian_1";
 
///////////////////////////////////////////////////////////////////////////
//                          END CONFIGURATION                            //
///////////////////////////////////////////////////////////////////////////
 
default
{
    state_entry() {
        llSensor("", NULL_KEY, (ACTIVE|PASSIVE), 96, TWO_PI);
    }
    attach(key id) {
        llResetScript();
    }
    on_rez(integer num) {
        llResetScript();
    }
    sensor(integer num) {
        key objKey = NULL_KEY;
        --num;
        do {
            if(llDetectedName(num) == NAME_OF_OBJECT && llList2Key(llGetObjectDetails(llDetectedKey(num), [OBJECT_OWNER]), 0) == llGetOwner()) {
                objKey = llDetectedKey(num);
                jump found_kitty;
            }
        } while(--num>-1);
        return;
@found_kitty;
        llParticleSystem([12,"0560a0ad-ee6e-9a87-6a27-9322bad689ce",5,<3.0e-2,3.0e-2,3.0e-2>,6,<5.0e-2,5.0e-2,5.0e-2>,1,<1,1,1>,3,<1,1,1>,2,((float)1.0),4,((float)1.0),15,((integer)10),13,((float)1.0e-3),7,((float)10.0),9,((integer)1),8,<.0,.0,-.1>,0,((integer)355),20,objKey]);
    }
}