Don't click here unless you want to be banned.

LSL Wiki : LockmeisterBaseFurniture

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org
Main script to put in the root/main poseball, the one that get cuffed

//KDC sample lockmeister furniture/device master script version 1.0
//
//INFO: this is a very basic multi point pose script, it combine the basic poseball style posing and the lockmeister pinging functions.

//NOTE: this script must be in the root prim of the object for working properly.
//...
//
//KDC, kyrah design concept


//this list contain the different lockmeister mooring points 
//to check for, add/remove the ones you will use using the list at:
//http://www.lslwiki.com/lslwiki/wakka.php?wakka=exchangeLockMeisterSystem
//to get the proper codes
list requests = ["lcuff","rcuff"];

//this is the offset you want to avatar to sit from, it is a 3 direction vector, X, Y, Z and it is relative to the root prim of your object.
//NOTE: if the vector is 0,0,0 the script will NOT work
vector sit_offset = <0,0,0.01>;

//this is the rotational offset for the avatar position
vector sit_rotation = <0,0,0>; // pitch yaw and roll are in degres here.

string animation = "put your anim here";//the animation wich must be in the same prim as this script.




/////////////////////////////////////////////////////
/////////////////SCRIPT START HERE///////////////////
/////////////////////////////////////////////////////

//few lazy constants
integer link = CHANGED_LINK;
integer set = LINK_SET;
string stop = "LMstop";
string N = "";
integer lockm_chan = -8888;
integer trigger = PERMISSION_TRIGGER_ANIMATION;
//some more
integer chan_handler;
integer count = 0;
default
{
    state_entry()
    {
        //setting the pose offset for the chained user.
        llSitTarget(sit_offset,llEuler2Rot(sit_rotation*DEG_TO_RAD));
    }
    changed(integer change)
    {
        // sit/unsit detected
        if((change & link) == link)
        {
            key avatar = llAvatarOnSitTarget();
            
            if(avatar == NULL_KEY)//unsit
            {
                llMessageLinked(set,0,stop,N);//stop particle chains
                if(llGetPermissionsKey() != NULL_KEY)//flush animation
                    llStopAnimation(animation);
                llResetScript();//reset script
            }
            else //sit
                llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
        }
    }
    run_time_permissions(integer perms)
    {
        if((perms & trigger) == trigger)//we got animation permission
        {
            llStopAnimation("sit");//flush base sit anim
            llStartAnimation(animation);//play our anim
            chan_handler = llListen(lockm_chan,"","","");//open the listener
            llSetTimerEvent(20.0);
            integer i;
            for(i=0;i < llGetListLength(requests);i+=1)
                llWhisper(lockm_chan,(string)llAvatarOnSitTarget()+llList2String(requests,i));
                //we run quickly all the ping messages
        }
    }
    listen(integer channel,string name,key id,string message)
    {
        if(llGetSubString(message,0,35) == (string)llAvatarOnSitTarget())//we filter only LockM messages for us
        {
            message = llDeleteSubString(message,0,35);//removing the header
            if(llGetSubString(message,-2,-1) == "ok") //its a message of the "ok" type (ping return)
            {
                message = llDeleteSubString(message,-3,-1);//removing the ok tag
                if(llListFindList(requests,[message]) != -1)//its a message we are looking for
                    llMessageLinked(set,0,message,id);
            }
        }
    }
    timer()
    {
        llListenRemove(chan_handler);
        llSetTimerEvent(0.0);
    }
}

anchor script, this script go into each of the chain "emitters"

//KDC sample lockmeister furniture/device anchor script version 1.0
//
//INFO: this is a very basic multi point pose script, it combine the basic poseball style posing and the lockmeister pinging functions.

//NOTE: this script must be in the prims wich are the chain "emitters" of the object for working properly., it is suggested to "orient the anchor prim (if you use invisible anchors) so that the z axis of the anchor point roughly toward the emission direction
//...
//
//KDC, kyrah design concept

string mooring_point = "rcuff";//here you define a working mooring point, for the kit to work the same mooring point must be present here and in the list of the root script.


chain(key target)
//customize the particles to your need , see here for more infos, http://www.lslwiki.com/lslwiki/wakka.php?wakka=llParticleSystem
{
    llParticleSystem([
    PSYS_PART_FLAGS,PSYS_PART_FOLLOW_VELOCITY_MASK|PSYS_PART_TARGET_POS_MASK|PSYS_PART_EMISSIVE_MASK,
    PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_ANGLE,
    PSYS_PART_START_SCALE,<0.08,0.08,0.0>,  //particles size X and Y
    PSYS_PART_MAX_AGE,2.0, //age of particles in seconds
    PSYS_SRC_OUTERANGLE,0.0,
    PSYS_SRC_BURST_RATE,0.001,//how often to release particles
    PSYS_SRC_BURST_SPEED_MIN,0.1,//speed of particles
    PSYS_SRC_BURST_SPEED_MAX,0.1,
    PSYS_SRC_TEXTURE,"",//your custom texture
    PSYS_SRC_TARGET_KEY,target,
    PSYS_SRC_BURST_PART_COUNT,1,//how many particles per burst
    PSYS_SRC_ACCEL,<0,0,0>//add a little bit of negative Z if you want the chain to "dangle" a little
    ]);
}

/////////////////////////////////////////////////////
/////////////////SCRIPT START HERE///////////////////
/////////////////////////////////////////////////////
default
{

    link_message(integer snum,integer num,string str,key id)
    {
        if(str == mooring_point)//we draw a chain
            chain(id);
        else if(str == "LMstop")//we stop it
            llParticleSystem([]);
    }
}
There is no comment on this page. [Display comments/form]