Jump to content
You are about to reply to a thread that has been inactive for 2950 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted
float fTimer = 10.0; //how long to go the entire distance
integer iSteps = 200; //how many steps to go from start to end
integer iLinknumber = 2; //link number of the moving prim
vector vAxis = <0.0,1.0,0.0>; //axis to move along. <1,0,0> is x-axis, <0,1,0> is y-axis, <0,0,1> is z-axis
integer iStep = 0; //control variable, don't change
default
{
    state_entry()
    { //start timer
        llSetTimerEvent((fTimer/iSteps));
    }
    timer()
    { //remove un-changeable axis-parameters from scale
        vector vScale = llGetScale();
        if (vAxis.x == 0.0) {vScale.x = 0;}
        if (vAxis.y == 0.0) {vScale.y = 0;}
        if (vAxis.z == 0.0) {vScale.z = 0;}
        if (iStep >= iSteps)
        { //reset step if last step was reached
            iStep = 0;
        }
        //set local position
        llSetLinkPrimitiveParamsFast(iLinknumber, [PRIM_POS_LOCAL, (-vScale / 2.0) + (vScale / iSteps)*iStep]);
        iStep++; //add 1 to step
    }
}

 

  • Like 1
Posted

Very nice script.  Because someone asked in the LSL Scripting Forum, here's a version that moves all child prims in the linkset along the chosen direction, keeping their initial positions in the "non-beam" directions constant.  For example, if the chosen beam direction is <1.0,0.0,0.0>, the child prims move back and forth along X, while keeping local Y and Z positions fixed.

float fTimer = 10.0; //how long to go the entire distanceinteger iSteps = 200; //how many steps to go from start to endvector vAxis = <1.0,0.0,0.0>; //axis to move along. <1,0,0> is x-axis, <0,1,0> is y-axis, <0,0,1> is z-axisinteger iStep = 0; //control variable, don't changeinteger k;  // ON/OFF switchinteger toggle; // Reverse direction of slidelist gHome;     // Starting positions of child primsdefault{        touch_start(integer num)    {        integer i;        k = !k;        if (k)        {         //ON            for (i=2;i<=llGetNumberOfPrims();++i)             {   //Loop to get the starting positions of all child prims                gHome += [llList2Vector(llGetLinkPrimitiveParams(i,[PRIM_POS_LOCAL]),0)];            }            iStep = 0;  //Set slide position at zero            llSetTimerEvent((fTimer/iSteps));            llOwnerSay("on");        }        else        {   //OFF            for (i=2;i<=llGetNumberOfPrims();++i)            {   //Loop to reposition all child prims at their starting positions                llSetLinkPrimitiveParamsFast(i, [PRIM_POS_LOCAL, llList2Vector(gHome,i-2)]);            }            gHome = []; // Empty the home position vector list            llSetTimerEvent(0);            llOwnerSay("off");            //  llResetScript();        }    }    timer()    { //remove un-changeable axis-parameters from scale        vector vScale = llGetScale();        if (vAxis.x == 0.0) {vScale.x = 0;}        if (vAxis.y == 0.0) {vScale.y = 0;}        if (vAxis.z == 0.0) {vScale.z = 0;}        if (iStep >= iSteps)        {            toggle = -1;                               }               else if (iStep <= 0)        {            toggle = 1;               }        integer i;        for (i=2;i<=llGetNumberOfPrims();++i)        {   // Loop for all child prims            llSetLinkPrimitiveParamsFast(i, [PRIM_POS_LOCAL, llList2Vector(gHome,i-2) + (vScale / iSteps)*iStep]);            iStep = iStep + toggle; //add 1 or -1 to step        }    }}

 

  • Like 1
  • 3 years later...
Posted

what about a version that only moves on child prim? would you input integer iLinknumber = 30; and then reconfigure the rest of the script for this to work smoothly? such as

(i=2;i<=llGetNumberOfPrims();++i)  to (i=2;i<=iLinknumber();++i)

You are about to reply to a thread that has been inactive for 2950 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...