Difference between revisions of "Phantom Child"

From Second Life Wiki
Jump to navigation Jump to search
m (Added note about it still working in server 1.36 to clarify a previous note.)
(Added version that maintains face params (textures and colors etc) Could prolly do with streamlining.)
Line 89: Line 89:
}
}
</lsl>
</lsl>
This version maintains the textures and colors on path cut and hollowed prims. Other than slice (no slice param in LSL yet see - [http://jira.secondlife.com/browse/SVC-5419 SVC-5419]) it seems that all params are maintained this way. Downside - Greater memory use and slower.
<lsl>list params;
GatherParams()
{
    integer length = 0;
    integer count = 0;
    integer side = 0;
    list extras = [];
    params += [9];
    params += llGetPrimitiveParams([9]);
    extras = llGetPrimitiveParams([17, ALL_SIDES]);
    length = llGetListLength(extras);
    do
    {
        params += [17];
        params += [(side++)];
        params += llList2List(extras, count, (count + 3));
        count = (count + 4);
    }
    while(count < length);
    count = 0;
    side = 0;
    extras = llGetPrimitiveParams([18, ALL_SIDES]);
    length = llGetListLength(extras);
    do
    {
        params += [18];
        params += [(side++)];
        params += llList2List(extras, count, (count + 1));
        count = (count + 2);
    }
    while(count < length);
    count = 0;
    side = 0;
    extras = llGetPrimitiveParams([19, ALL_SIDES]);
    length = llGetListLength(extras);
    do
    {
        params += [19];
        params += [(side++)];
        params += llList2List(extras, count, (count + 1));
        count = (count + 2);
    }
    while(count < length);
    count = 0;
    side = 0;
    extras = llGetPrimitiveParams([20, ALL_SIDES]);
    length = llGetListLength(extras);
    do
    {
        params += [20];
        params += [(side++)];
        params += llList2List(extras, count, count);
        count = (count + 1);
    }
    while(count < length);
    count = 0;
    side = 0;
    extras = llGetPrimitiveParams([22, ALL_SIDES]);
    length = llGetListLength(extras);
    do
    {
        params += [22];
        params += [(side++)];
        params += llList2List(extras, count, count);
        count = (count + 1);
    }
    while(count < length);
    count = 0;
    side = 0;
    extras = llGetPrimitiveParams([25, ALL_SIDES]);
    length = llGetListLength(extras);
    do
    {
        params += [25];
        params += [(side++)];
        params += llList2List(extras, count, count);
        count = (count + 1);
    }
    while(count < length);
}
default
{
    state_entry()
    {
        GatherParams();
        llSetPrimitiveParams([9, 0, 0, <0.0,1.0,0.0>, 0, <0.0,0.0,0.0>, <1.0,1.0,0.0>, <0.0,0.0,0.0>,
                              PRIM_FLEXIBLE, TRUE, 0, 0, 0, 0, 0, <0.0,0.0,0.0>] + params);
        params = [];
    }
    changed(integer change)
    {
        if(change & CHANGED_REGION_START)
        llResetScript();
    }
    on_rez(integer param)
    {
        llResetScript();
    }
    collision_start(integer nd)
    {
        llResetScript();
    }
}</lsl>


{{LSLC|Library}}
{{LSLC|Library}}
{{LSLC|Examples}}
{{LSLC|Examples}}

Revision as of 21:01, 11 April 2010

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 the textures and colors on path cut and hollowed prims. Other than slice (no slice param in LSL yet see - SVC-5419) it seems that all params are maintained this way. Downside - Greater memory use and slower.

<lsl>list params;

GatherParams() {

   integer length = 0;
   integer count = 0;
   integer side = 0;
   list extras = [];
   params += [9];
   params += llGetPrimitiveParams([9]);
   extras = llGetPrimitiveParams([17, ALL_SIDES]);
   length = llGetListLength(extras);
   do
   {
       params += [17];
       params += [(side++)];
       params += llList2List(extras, count, (count + 3));
       count = (count + 4);
   }
   while(count < length);
   count = 0;
   side = 0;
   extras = llGetPrimitiveParams([18, ALL_SIDES]);
   length = llGetListLength(extras);
   do
   {
       params += [18];
       params += [(side++)];
       params += llList2List(extras, count, (count + 1));
       count = (count + 2);
   }
   while(count < length);
   count = 0;
   side = 0;
   extras = llGetPrimitiveParams([19, ALL_SIDES]);
   length = llGetListLength(extras);
   do
   {
       params += [19];
       params += [(side++)];
       params += llList2List(extras, count, (count + 1));
       count = (count + 2);
   }
   while(count < length);
   count = 0;
   side = 0;
   extras = llGetPrimitiveParams([20, ALL_SIDES]);
   length = llGetListLength(extras);
   do
   {
       params += [20];
       params += [(side++)];
       params += llList2List(extras, count, count);
       count = (count + 1);
   }
   while(count < length);
   count = 0;
   side = 0;
   extras = llGetPrimitiveParams([22, ALL_SIDES]);
   length = llGetListLength(extras);
   do
   {
       params += [22];
       params += [(side++)];
       params += llList2List(extras, count, count);
       count = (count + 1);
   }
   while(count < length);
   count = 0;
   side = 0;
   extras = llGetPrimitiveParams([25, ALL_SIDES]);
   length = llGetListLength(extras);
   do
   {
       params += [25];
       params += [(side++)];
       params += llList2List(extras, count, count);
       count = (count + 1);
   }
   while(count < length);

}

default {

   state_entry()
   {
       GatherParams();
       llSetPrimitiveParams([9, 0, 0, <0.0,1.0,0.0>, 0, <0.0,0.0,0.0>, <1.0,1.0,0.0>, <0.0,0.0,0.0>,
                             PRIM_FLEXIBLE, TRUE, 0, 0, 0, 0, 0, <0.0,0.0,0.0>] + params);
       params = [];
   }
   changed(integer change)
   {
       if(change & CHANGED_REGION_START)
       llResetScript();
   }
   on_rez(integer param)
   {
       llResetScript();
   }
   collision_start(integer nd)
   {
       llResetScript();
   }

}</lsl>