User:Mr Lovenkraft

From Second Life Wiki
Revision as of 17:12, 3 February 2008 by Mr Lovenkraft (talk | contribs) (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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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>