Difference between revisions of "User:Mr Lovenkraft"

From Second Life Wiki
Jump to navigation Jump to search
(New page: ==Open source codes from Mr Lovenkraft== ---- I've just starting this page in the hopes of having quite a few codes open sourced for those of you who either can't find what you are looking...)
 
Line 103: Line 103:
</lsl>
</lsl>
----
----
===Stop all animations: basic===
<lsl>
//Stop all animations by Mr Lovenkraft
//Useful learning codes from the large inventory of Mr Lovenkraft ;)
list anims;
key av;
default
{
    touch_start(integer total_number)
    {
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);//Dur, requests permissions.
        av = llDetectedKey(0); //Person to stop animations for.
    }
    run_time_permissions(integer perm)//Runs if we get permissions.
    {
        anims = []; //Clears the list of any past animations.
        anims = llGetAnimationList(av); //Gets the current users animations playing.
        integer index = llGetListLength(anims); //The amount of animations for stopping.
        integer i; //Starting place for our loop.
        for(i=0; i<index; i++)//Runs through for each animation in the list.
        {
            llStopAnimation(llList2String(anims, i)); //Stops the animation in the list at point i.
        }
    }
}
</lsl>

Revision as of 16:14, 3 February 2008

Open source codes from Mr Lovenkraft


I've just starting this page in the hopes of having quite a few codes open sourced for those of you who either can't find what you are looking for, or just want an easy place to look for codes :)


Removable prim clothing script

This script is written to be placed in the root prim of an object. <lsl> //Removable clothing by Mr Lovenkraft, free to use by anyone. //Fully open source, but credit going to Mr Lovenkraft for his effort :) key user; //Person touching the clothing. key owner; //The owner of course O.o integer diaChan; //Random Dialog channel to prevent other clothing items from listening.. integer listenNum; //Used to start a listen, and remove it. list buttons = ["Tear", "Look", "Flick", "Tug"];//Buttons to click on of course. integer touchable = TRUE; integer removeable; int()//The actual starting menu and calculating random channel to listen on. {

   touchable = FALSE;
   diaChan = llCeil(llFrand(-9999999));
   if(diaChan >= 0) //Just in case it returns 0, we want a negative listen :)
   {
       diaChan += llRound(llFrand(-9999999)); //Recalculate
   }
   listenNum = llListen(diaChan, "", "", "");//Listen handler to remove listen when done.
   llDialog(user, "What would you like to do?", buttons, diaChan); //Menu with the buttons o.o
   llSetTimerEvent(15); //Menu time out, in case someone doesn't pick an option :)

} default {

   on_rez(integer r)
   {
       owner = llGetOwner(); //Of course it gets the owner O.o
   }
   state_entry()
   {
       owner = llGetOwner(); //Again just in case it didn't get the point.
   }
   touch_start(integer total_number)
   {
       if(touchable) //If it hasn't been touched, let it be touched
       {
           user = llDetectedKey(0); //Makes the person touching, the owner.
           int(); //When touched, get the random channel.
       }
   }
   attach(key av)
   {
       if(av)
       {
           removeable = TRUE; //If actually on an av, allow clothing to request permissions for detach.
       }
       else
       {
           removeable = FALSE; //Oposite if no av :)
       }
   }
   run_time_permissions(integer perm)
   {
       if(perm & PERMISSION_ATTACH)
       {
           llWhisper(0, llKey2Name(user) + " rips " + llKey2Name(owner) +"'s clothing right off!");
           llDetachFromAvatar( ); //Detach from av of course.
       }
   }
   listen(integer chan, string name, key id, string msg)
   {
       if(llToLower(msg)=="tug") //We use llToLower(msg) so that it's not case sensitive. :)
       {
           llWhisper(0, llKey2Name(user) + " tugs on " + llKey2Name(owner) +"'s clothing.");
       }
       if(llToLower(msg)=="flick")
       {
           llWhisper(0, llKey2Name(user) + " flicks " + llKey2Name(owner) +"'s clothing.");
       }
       if(llToLower(msg)=="look")
       {
           llWhisper(0, llKey2Name(user) + " looks at " + llKey2Name(owner) +"'s clothing.");
       }
       if(llToLower(msg)=="tear")
       {
           if(removeable)
           {
               llRequestPermissions(owner, PERMISSION_ATTACH);
           }
           else
           {
               llWhisper(0, "Can not remove clothing that is not worn.");
           }
       }
       touchable = TRUE;
       llListenRemove(listenNum); //Stop listening to prevent lag :)
   }
   timer()
   {
       touchable = TRUE;
       llSetTimerEvent(0.0); //Stops the timer
       llWhisper(0, "Menu time out...");
   }

} </lsl>


Stop all animations: basic

<lsl> //Stop all animations by Mr Lovenkraft //Useful learning codes from the large inventory of Mr Lovenkraft ;) list anims; key av; default {

   touch_start(integer total_number)
   {
       llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);//Dur, requests permissions.
       av = llDetectedKey(0); //Person to stop animations for.
   }
   run_time_permissions(integer perm)//Runs if we get permissions.
   {
       anims = []; //Clears the list of any past animations.
       anims = llGetAnimationList(av); //Gets the current users animations playing.
       integer index = llGetListLength(anims); //The amount of animations for stopping.
       integer i; //Starting place for our loop.
       for(i=0; i<index; i++)//Runs through for each animation in the list.
       {
           llStopAnimation(llList2String(anims, i)); //Stops the animation in the list at point i.
       }
   }

} </lsl>