Neverworld Grid

You are not logged in. Would you like to login or register?



6/10/2019 6:04 pm  #1


Logan's Build Exploder

/*
    Logan Exploder/Breaker-Upper V2.2
    Copylefted Mar-22-2016 Logan Stargazer
    Reassembly added by Christine Nyn, 23-March-2016

    This is a tool to explode a build apart so you can see what
    those parts are. Unlike the previous version this one explodes
    in a proper circle around the root prim instead of straight up.
    Therefore I suggest you do this to an object at some altiutude
    above ground.  The object will not be unlinked after this operation.

    Just rez a ***COPY*** of some muli-prim object, drop this script
    onto it and watch the fun.
    
    First click explodes, second click reassembles. Delete the script from
    the object when you no longer need it.

    ToDo:
    Cause each link to un-link, turn physical and explode into a shower
    of flames when it strikes the ground. NOOOOO but that would be cool!
*/

integer LinkCount;
integer exploded;
float offset = 0.5;// Adjust to suit
list vectors;

vector calc_xyz(integer link, vector value)
{
    integer OK;
    value.x *= 3.0;
    if(llFabs(value.x) > offset) 
    {
        OK = TRUE;
    }
    value.y *= 3.0;
    if(llFabs(value.y) > offset)
    {
        OK = TRUE;
    }
    value.z *= 3.0;
    if(llFabs(value.y) > offset)
    {
        OK = TRUE;
    }
    if(OK) return value;
    vector size = llList2Vector(llGetLinkPrimitiveParams(link, [PRIM_SIZE]), 0);
    value.z += size.z;
    return value;
}

default
{
    touch_start(integer foo)
    {
        LinkCount = llGetNumberOfPrims();
        integer i;
        vector LinkLocInfo;
        if(!exploded)
        {
            vectors = [];
            for(i = 2; i <= LinkCount; i++)
            {
                // Get the relative location of the link
                LinkLocInfo = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_POS_LOCAL]), 0);
                vectors += [LinkLocInfo];
                // Increase that info by a factor of 3
                LinkLocInfo = calc_xyz(i, LinkLocInfo);
             
                // Reposition the link
                llSetLinkPrimitiveParamsFast(i, [PRIM_POS_LOCAL,LinkLocInfo]);
            }
            llOwnerSay("It blowed up real good!\nNow you can examine it or unlink it and get the parts.");
            exploded = TRUE;
        }
        else
        {
            for(i = 2 ; i <= LinkCount; i++)
            {
                LinkLocInfo = llList2Vector(vectors, i - 2);
                llSetLinkPrimitiveParamsFast(i, [PRIM_POS_LOCAL, LinkLocInfo]);
            }
            llOwnerSay("Zappo!\nAnd now it's back together.");
            exploded = FALSE;
        }
    }
}  

 

Board footera

 

Powered by Boardhost. Create a Free Forum