Jump to content
Sign in to follow this  
MartinRJ Fayray

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

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

Share this post


Link to post
Share on other sites

You need to sit on it.  Ideally, you would customize the script by adding a sit target and possibly a sit animation as well.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...