News: SMF - Just Installed!
Welcome, Guest. Please login or register.
Did you miss your activation email?

 Raglan Shire ForumsRaglan ShireThe VaultScriptsTopic: One script to sit them all, and in the comfort, seat them
Pages: [1]   Go Down
Print
Author Topic: One script to sit them all, and in the comfort, seat them  (Read 1107 times)
Pipa Novelli
Friend of the Shire

Offline Offline

Posts: 0


View Profile
« on: February 15, 2016, 10:19:40 PM »

Put this script in any prim of a link set that has chairs and set ALL the sit targets with one script.  Name your chairs 'chair' (you can call then 'Fred' if you want, as long as you reflect that in the script).  

This saves the hassle of adjusting lots of seats in a build like a cinema or stadium.  Sit positions will apply to all the seats in the link set.

.........................................................................

vector SIT_POS = <0.25, -0.0, 0.5>; // The sit offset for the chair
vector SIT_ROT = <1.0, 0.0, 00.0>; // The sit rotation in degrees (must not be xero rotation to work)


get_chairs() //This is a custom 'find the chairs' function
{
    integer i;  // Define a blank integer to work with.
    integer l = llGetNumberOfPrims() + 1; // Count the prims in the linkset and add one for good measure
        
    for(i = 0; i < l ; ++i) //A 'for' loop starts i as 0 then adds 1 to it until i equals the number of prims plus one.
    {
        if(llGetLinkName(i) == "chair") //If link number i is called 'chair'
        {
            llLinkSitTarget( i ,  SIT_POS, llEuler2Rot(SIT_ROT * DEG_TO_RAD)); //Apply the sit script to it.
        }
    }    
}


 
default // Script atarting point.
{
    state_entry()
    {
        get_chairs(); // Find out which prims are a chair
    }
    changed(integer change)
    {
        if(change & CHANGED_LINK) //If someonee sits down or prims have been added or removed.
        {
            get_chairs();  // Find out which prims are a chair
        }
    }
 
}
« Last Edit: February 16, 2016, 06:10:50 AM by Pipa Novelli » Logged
Kayak Kuu
Friend of the Shire

Offline Offline

Posts: 27



View Profile
« Reply #1 on: February 16, 2016, 05:25:26 AM »

Interesting, got to try this, thanks Pipa :-)
Logged

Otters Rule :-)
Pages: [1]   Go Up
Print
 Raglan Shire ForumsRaglan ShireThe VaultScriptsTopic: One script to sit them all, and in the comfort, seat them
Jump to: