Jump to content

Garden Swing Script - put into a rod (ROOTPRIM) at the axis of the swing


MartinRJ Fayray
 Share

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

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

Recommended Posts

integer swinging = FALSE; //set TRUE if you want the swing to initially swing
float fTimer = 0.01; //pause between animation-steps (in seconds)
list lSwinging = [11,4,8,6,7,5,9,10]; //list of swinging prims (fill in all LINKNUMBERS that should be swinging)
integer iDegrees = 15; //degrees to move back and forth
integer iSteps = 20; //number of steps for the animation


float fDegree = 0; //global variable, stores current degrees
integer iDirectionPos = TRUE; //global variable, stores direction
default
{
    touch_start(integer total_number)
    {
        if (swinging)
        {
            swinging = FALSE;
            llSetTimerEvent(0);
        }
        else
        {
            swinging = TRUE;
            llSetTimerEvent(fTimer);
        }
    }
    timer()
    {
        integer i;
        rotation r;
        vector v;
        integer l;
        for (i = 0; i < llGetListLength(lSwinging); i++)
        {
            l = llList2Integer(lSwinging, i);
            r = llList2Rot(llGetLinkPrimitiveParams(l, [PRIM_ROT_LOCAL]),0);
            v = llList2Vector(llGetLinkPrimitiveParams(l, [PRIM_POS_LOCAL]),0);
            llSetLinkPrimitiveParamsFast(l, [PRIM_POS_LOCAL, v * llEuler2Rot(<0,0,((float)fDegree / (float)iSteps)>*DEG_TO_RAD)]);
            llSetLinkPrimitiveParamsFast(l, [PRIM_ROT_LOCAL, r * llEuler2Rot(<0,0,((float)fDegree / (float)iSteps)>*DEG_TO_RAD)]);
        }
        if (iDirectionPos)
        {
            fDegree = fDegree + ((float)iDegrees / (float)iSteps);
            if (fDegree > iDegrees)
            {
                iDirectionPos = FALSE;
            }
        }
        else
        {
            fDegree = fDegree - ((float)iDegrees / (float)iSteps);
            if (fDegree < -iDegrees)
            {
                iDirectionPos = TRUE;
            }
        }
    }
}

 

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

I'm probably beating a dead horse here since it was posted a while back but to fix this issue you have to take into account that the script counts your avatar as a linked prim so if you want the avatar to swing with the linked prims you have to include another number to the list. If your swing is 4 prims total you would add a 5 to the list to include the avatar. All that is needed next is a sit script in the prim you want to sit on to position the avatar.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2520 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
 Share

×
×
  • Create New...