AS Flexi Wing Flap - Second Life Wiki

AS Flexi Wing Flap

From Second Life Wiki

Second Life Wiki > AS Flexi Wing Flap
Jump to: navigation, search
/* 
  Change the gravity settings on flexi child prims named "WING"
  each second to simulate flapping.
*/
 
// Gravity settings for the flaps
float UP = 1.0;
float DOWN = -1.0;
float MID = 0.0;
// Looping order of the flaps
list FLAPS = [ UP, DOWN, UP, DOWN, UP, DOWN, MID, MID, MID, MID ];
// internal values
integer current_flap = 0;
list WingIDs = [];
 
list LinkedList(string Needle) {
    list Needles;
    integer Hay = 1;
    integer Stacks = llGetNumberOfPrims();
    for(; Hay <= Stacks; ++Hay ) if(llGetLinkName(Hay) == Needle) Needles += Hay;
    return Needles;
}
 
default
{
    state_entry() {
        WingIDs = LinkedList( "WING" );
        llSetTimerEvent( 1.0 );
    }
 
    timer() {
        if ( current_flap >= llGetListLength(FLAPS) ) current_flap = 0;
 
        integer x = llGetListLength(WingIDs);
        integer y = 0;
        for ( ; y < x; ++y )
        {
            llSetLinkPrimitiveParamsFast( llList2Integer( WingIDs, y ), 
                                          [PRIM_FLEXIBLE, TRUE, 1, 
                                          llList2Integer(FLAPS, current_flap), 
                                          0.0, 0.0, 1.0 , <0, 0, 0>]);
        }
 
        ++current_flap;
    }
}