Phantom Child

From Second Life Wiki
Revision as of 21:51, 12 April 2010 by Fred Gandt (talk | contribs) (Damn top size freakin stupid broken....)
Jump to navigation Jump to search

Phantom Child

This easy to use code when put into a child prim of a linkset will make that child and only that child phantom, even when taken into inventory and re-rezzed. You can use multiple copies of this script to make multiple children of a linkset phantom.

This code relies on a bug in Secondlife and may not function in later versions (currently server version 1.24)(UPDATE: Still works in server 1.36). This script was created in part by Aeron Kohime and documents this useful bug (which like invis-prims, has countless applications).

You may use the following script in any manner you like, excluding claiming you made it and individually reselling it without change in function (its on the wiki silly). Otherwise you can sell it as part of a product, modify it, remove my comments, etc etc.

It needs to be reset on sim restarts. one possible solution is included below. Checking llGetTime in a timer may be another.

<lsl> //Phantom Child Script by Aeron Kohime //WARNING: When used on the root prim it makes the entire object phantom, it // also does not function correctly on tortured prims. (Sorry.) //Reset on Sim restart added by Void Singer //Strife Onizuka was here doing simplification //Reset on collision added by Taff Nouvelle (my stairs kept reverting) //Psi Merlin updated CHANGED_REGION_START (live as of Server 1.27)

default {

   state_entry() {
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX,
           0, <0,1,0>, 0, <0,0,0>, <1,1,0>, <0,0,0>,
           PRIM_FLEXIBLE, TRUE, 0, 0, 0, 0, 0, <0,0,0>,
           PRIM_TYPE] + llGetPrimitiveParams([PRIM_TYPE]));
   }

   on_rez(integer s) {
       llResetScript();
   }

   //-- This event/test will reset the script on sim restart.
   changed (integer vBitChanges){
       if (CHANGED_REGION_START & vBitChanges){
           llResetScript();
       }
   }
   collision_start(integer num_detected){
       llResetScript();
       
   }

} </lsl>

Addition to this script, a switchable version that is useful for a phantom door.

<lsl>

//Phantom Child Script by Aeron Kohime //WARNING: When used on the root prim it makes the entire object phantom, it // also does not function correctly on tortured prims. (Sorry.) //Reset on Sim restart added by Void Singer //Strife Onizuka was here doing simplification //Phantom door idea added by Taff Nouvelle //Psi Merlin updated CHANGED_REGION_START (live as of Server 1.27)

integer a = 1;

default

{
   state_entry()
   {
   }
   touch_start(integer total_number)
   {
   a*=-1;
   if(a == 1)
   {
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX,
           0, <0,1,0>, 0, <0,0,0>, <1,1,0>, <0,0,0>,
           PRIM_FLEXIBLE, TRUE, 0, 0, 0, 0, 0, <0,0,0>,
           PRIM_TYPE] + llGetPrimitiveParams([PRIM_TYPE])); 
           llOwnerSay ("Phantom");
   }
   else
   {
       llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
       llOwnerSay ("Solid");
   }

}

   on_rez(integer s) {
       llResetScript();
   }
   changed (integer vBitChanges){
       if (CHANGED_REGION_START & vBitChanges){
           llResetScript();
       }
   }

} </lsl>

This version maintains all parameters of the child prim. Path cut, hollow, textures, twist etc. Everything remains the same except the child becomes phantom. Because setting a sculpted prim as flexible cannot be done at this time (server 1.36) provision must be made to maintain the params in that case. This version does that. It can thus be used to make any type of child prim that is not supposed to be flexible phantom.

<lsl>default {

   state_entry()
   {
       list box = [];
       list sculpt = [];
       list type = llGetPrimitiveParams([9]);
       if(llList2Integer(type, 0) == 7)
       {
           box = [9, 0, 0, <0.0,1.0,0.0>, 0.0, <0.0,0.0,0.0>, <1.0,1.0,0.0>, <0.0,0.0,0.0>];
           sculpt = [9] + type;
       }
       llSetPrimitiveParams(box + [21, 1, 0, 0.0, 0.0, 0.0, 0.0, <0.0,0.0,0.0>,
                                   21, 0, 0, 0.0, 0.0, 0.0, 0.0, <0.0,0.0,0.0>] + sculpt);
   }
   changed(integer change)
   {
       if(change & CHANGED_REGION_START)
       llResetScript();
   }
   on_rez(integer param)
   {
       llResetScript();
   }
   collision_start(integer nd)
   {
       llResetScript();
   }

}</lsl>