MLPV2 Rez Prop Independent of Pose Master

From Second Life Wiki
Revision as of 15:38, 11 February 2014 by Chaz Longstaff (talk | contribs)
Jump to navigation Jump to search

Companion script: ~prop permanent derezzer" (ITEM)


<lsl> //MASTER "~prop permanent rezzer" script //version 1.2 by Chaz Longstaff 2014-02-9

//PURPOSE //to rez an item semi-permanently from MLP menu independent of a pose //when the item is rezzed, it will stay rezzed until it hears a command to go away

//there are 3 parts needed: //1. Your menu commands in the MLP menu notecard; //2. This script that goes into the MLP along with other MLP scripts -- "~prop permanent rezzer" (MASTER) script; //3. A small script "~prop permanent derezzer" (ITEM) that you put into each item that you will semi-permanently rez; this listens for the derez command later. //you can of course name the scripts whatever you want, the name of the scripts doesn't actually matter.


//instructions //1. put this "~prop permanent rezzer" script inside the MLP product with the other MLP Scripts //2. put the script "~prop permanent derezzer" in objects you are going to rez "semi-permanently" //3. add menu buttons to your MLP .MENUITEMS notecard as follows // //format of menu buttons: // //LINKMSG Rez AThing| 0,-4,987790,Rez##Tiki Torch bb Rezable ##X#.15#.70 //LINKMSG DeRez AThing | 1,-4,987790,DeRez##ItemToRez

//X Y Z are the coordinates that you have figured out manually by placing an object where you want it, editing it, and making a note of the XYZ. Separate each of them with a single # //Yes, that means the rotation is hard coded, so you just need to make your prop something that doesn't need rotational adjustments during rezzing. Sorry about that, rotations do //my head in so I suck at them! Someone whose head can handle rotations is welcome to mod this to add flexible rotations on if they want...


integer ch; string ObjectName; vector TargetVector; integer x;


integer IsVector(string str) {

   if ( (vector)str )
       return TRUE;
    if(llSubStringIndex(str, "<")  != -1) 
       if(llSubStringIndex(str, ">")  != -1) 
           if(llGetListLength(llParseStringKeepNulls(str, [","], [])) == 3)
               return TRUE;
    return FALSE; 

}


default {

   on_rez(integer start) {
       llResetScript(); 
       
   }
   
   
   
   state_entry() {
   }
   
   
     link_message(integer from, integer num, string str, key id) {
        if (num == 987790) { 
           list TempList1 = llParseStringKeepNulls(str,["##"],[]);
           string status = llStringTrim(llList2String(TempList1, 0),STRING_TRIM);
           if (status == "DeRez") {
               llShout(ch, str);
               return; 
           }
           
           ObjectName = llStringTrim(llList2String(TempList1, 1),STRING_TRIM);
           string params = llStringTrim(llList2String(TempList1, 2),STRING_TRIM);
           list TempList2 = llParseStringKeepNulls(params,["#"],[]);
           string tmpx = llStringTrim(llList2String(TempList2, 0),STRING_TRIM);
           if (tmpx == "") tmpx = "0";
           string tmpy = llStringTrim(llList2String(TempList2, 1),STRING_TRIM);
           if (tmpy == "") tmpy = "0";
           string tmpz = llStringTrim(llList2String(TempList2, 2),STRING_TRIM);
           if (tmpz == "") tmpz = "0";               
           TargetVector = <0 + (float)tmpx, 0 + (float)tmpy, 0 + (float)tmpz>;
           //TargetVector = llEuler2Rot(TargetVector );
           string object = "Object"; // Name of object in inventory
           vector relativePosOffset = TargetVector; // "Forward" and a little "above" this prim
           vector relativeVel = <0.0, 0.0, 0.0>; // Traveling in this prim's "forward" direction at 1m/s
           rotation relativeRot = <0.0, 0.0, 0.0, 90>; // Rotated 90 degrees on the x-axis compared to this prim
           if (IsVector( (string)TargetVector  )) {
               "";
               //I forget what I wanted to do here!
           }   
           
           
           if (status == "Rez") {
               vector myPos = llGetPos();
               rotation myRot = llGetRot();
               vector rezPos = myPos+relativePosOffset*myRot;
               vector rezVel = relativeVel*myRot;
               rotation rezRot = relativeRot*myRot;
               llRezAtRoot(ObjectName, rezPos, rezVel, rezRot, ch);                      
            }
       }
           
           
   }

} </lsl>