Basic Leash
From Second Life Wiki
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Created by Kira Komarov for Mandy Deed.
Introduction
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.
Setup
- Create a new script in a primitive of your choosing and copy-paste the code below.
- Configure the script and set NAME_OF_OBJECT to the name of the object towards which the leash particles will be sent to.
Code
////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // 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) { llSensor("", NULL_KEY, (ACTIVE|PASSIVE), 96, TWO_PI); } on_rez(integer num) { llSensor("", NULL_KEY, (ACTIVE|PASSIVE), 96, TWO_PI); } sensor(integer num) { key objKey = NULL_KEY; integer itra; for(itra=0; itra<num; ++itra) { if(llDetectedName(itra) == NAME_OF_OBJECT && llList2Key(llGetObjectDetails(llDetectedKey(itra), [OBJECT_OWNER]), 0) == llGetOwner()) { objKey = llDetectedKey(itra); jump found_kitty; } } 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.0,1.0,1.0>, 3,<1.0,1.0,1.0>, 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,0.0,-0.1>, 0,((integer)355), 20,objKey]); } }

