Difference between revisions of "Phantom Child"

From Second Life Wiki
Jump to navigation Jump to search
m (Oooh...I used a template. Wonders may never cease. ;-))
m (I cannot find any floor is this way of setting a phantom child. It works.)
Line 90: Line 90:
</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 - {{JIRA|SVC-5419}}) it seems that all params are maintained this way. Downside - Greater memory use and slower.
This version maintains all parameters of the child prim. Path cut, hollow, textures, twist etc. Everything remains the same except the child becomes phantom.


<lsl>list MyParams()
<lsl>default
{
    integer l;
    integer c;
    integer f;
    list s;
    list p = [9];
    p += llGetPrimitiveParams([9]);
    s = llGetPrimitiveParams([17, -1]);
    l = llGetListLength(s);
    do
    {
        p += [17, (f++)];
        p += llList2List(s, c, (c + 3));
        c = (c + 4);
    }
    while(c < l);
    c = 0;
    f = 0;
    s = llGetPrimitiveParams([18, -1]);
    l = llGetListLength(s);
    do
    {
        p += [18, (f++)];
        p += llList2List(s, c, (c + 1));
        c = (c + 2);
    }
    while(c < l);
    c = 0;
    f = 0;
    s = llGetPrimitiveParams([19, -1]);
    l = llGetListLength(s);
    do
    {
        p += [19, (f++)];
        p += llList2List(s, c, (c + 1));
        c = (c + 2);
    }
    while(c < l);
    c = 0;
    f = 0;
    s = llGetPrimitiveParams([20, -1]);
    l = llGetListLength(s);
    do
    {
        p += [20, (f++)];
        p += llList2List(s, c, c);
        c = (c + 1);
    }
    while(c < l);
    c = 0;
    f = 0;
    s = llGetPrimitiveParams([22, -1]);
    l = llGetListLength(s);
    do
    {
        p += [22, (f++)];
        p += llList2List(s, c, c);
        c = (c + 1);
    }
    while(c < l);
    c = 0;
    f = 0;
    s = llGetPrimitiveParams([25, -1]);
    l = llGetListLength(s);
    do
    {
        p += [25, (f++)];
        p += llList2List(s, c, c);
        c = (c + 1);
    }
    while(c < l);
    return p;
}
 
default
{
{
     state_entry()
     state_entry()
     {
     {
        // Memory reading taken on a default cube.
         llSetPrimitiveParams([21, 1, 0, 0.0, 0.0, 0.0, 0.0, <0.0,0.0,0.0>, // Make the child flexible.
        // Free Memory (on first run) = 57056
                              21, 0, 0, 0.0, 0.0, 0.0, 0.0, <0.0,0.0,0.0>]); // Make the child non-flexible.
        // Free Memory (after reset) = 57084
       
        list params = MyParams();
       
        // Free Memory (on first run & after reset) = 53464
       
         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>,
                              21, 1, 0, 0, 0, 0, 0, <0.0,0.0,0.0>] + params);
        llOwnerSay("Phantom Child");
       
        // Free Memory (on first run & after reset) = 53416
     }
     }
     changed(integer change)
     changed(integer change)

Revision as of 14:34, 12 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 all parameters of the child prim. Path cut, hollow, textures, twist etc. Everything remains the same except the child becomes phantom.

<lsl>default {

   state_entry()
   {
       llSetPrimitiveParams([21, 1, 0, 0.0, 0.0, 0.0, 0.0, <0.0,0.0,0.0>, // Make the child flexible.
                             21, 0, 0, 0.0, 0.0, 0.0, 0.0, <0.0,0.0,0.0>]); // Make the child non-flexible.
   }
   changed(integer change)
   {
       if(change & CHANGED_REGION_START)
       llResetScript();
   }
   on_rez(integer param)
   {
       llResetScript();
   }
   collision_start(integer nd)
   {
       llResetScript();
   }

}</lsl>