Jet Pack Script

Expired

integer moving = FALSE;
integer flying = FALSE;

default
{
    attach(key on)
    {
        if (on != NULL_KEY)
        {
            llLoopSound("boom", 1.0);
            moving = TRUE;
            integer perm = llGetPermissions();
            
            if (perm != (PERMISSION_TAKE_CONTROLS))
            {
                llRequestPermissions(on, PERMISSION_TAKE_CONTROLS);
            }
            else
            {
                llTakeControls(CONTROL_FWD | CONTROL_ML_LBUTTON, TRUE, TRUE);
                llSetTimerEvent(0.5);
            }
        }
        else
        {
            moving = FALSE;
            llStopSound();
            llReleaseControls();
            llSetTimerEvent(0.0); 
        }
    }
    
    timer()
    {
        if(llGetAgentInfo(llGetOwner()) & AGENT_FLYING)
        {
            if(flying == FALSE)
            {
                        

vector I_start_color = <1 ,1,1>;
vector I_end_color = <0.5,0,0.2>; 

float I_start_alpha = 0.0; 
float I_end_alpha = 1.0;   

vector I_start_scale = <0.3,0.3,0.0>;   
vector I_end_scale = <0,0,0>;    

float I_particle_age = 1.5;

float I_inner_angle = PI; 
float I_outer_angle = PI; 
vector I_spin_speed = <0.0,0.0,0.0>;   

vector I_particle_accel = <0.0,0.0,0.0>;

float I_burst_rate = 0.1;
integer I_burst_count = 50;
float I_burst_radius = 0.05;
float I_min_speed = 0.1;
float I_max_speed = 0.65;

float I_source_age = 0.0;  // 0.0 = forever

string I_particle_texture = "particle_glowWhite2"; //if not defined, the default particle

key I_target; //the target of your particles if they use a follow mask


        llParticleSystem([
            PSYS_PART_FLAGS, 
                PSYS_PART_INTERP_COLOR_MASK |
                PSYS_PART_INTERP_SCALE_MASK |
              
                PSYS_PART_FOLLOW_SRC_MASK |
                PSYS_PART_FOLLOW_VELOCITY_MASK |
              
                PSYS_PART_EMISSIVE_MASK, 
         
                     
            PSYS_PART_START_COLOR, I_start_color,
            PSYS_PART_END_COLOR, I_end_color,
                     
         
                     
            PSYS_PART_START_SCALE, I_start_scale,
            PSYS_PART_END_SCALE, I_end_scale,
                     
            PSYS_PART_MAX_AGE, I_particle_age,
                     
            
            PSYS_SRC_PATTERN,
                PSYS_SRC_PATTERN_ANGLE_CONE,
            
            PSYS_SRC_INNERANGLE, I_inner_angle,
            PSYS_SRC_OUTERANGLE, I_outer_angle,
            PSYS_SRC_OMEGA, I_spin_speed,
            
            PSYS_SRC_ACCEL,  I_particle_accel,
            
            PSYS_SRC_TEXTURE, I_particle_texture,
            
            PSYS_SRC_BURST_RATE, I_burst_rate,
            PSYS_SRC_BURST_PART_COUNT, I_burst_count,
            PSYS_SRC_BURST_RADIUS, I_burst_radius,
            PSYS_SRC_BURST_SPEED_MIN, I_min_speed,
            PSYS_SRC_BURST_SPEED_MAX, I_max_speed,
            
            PSYS_SRC_MAX_AGE, I_source_age
            ]);
        }
            
            flying = TRUE;
            llMessageLinked(LINK_SET, 0, "fly", "");
            //..................IDLE...............................

        }
        else
        {
            flying = FALSE;
            llMessageLinked(LINK_SET, 0, "nofly", "");
            llParticleSystem([]);
        }
    }
            
        

    run_time_permissions(integer perm)
    {
        if (perm)
        {
            llTakeControls(CONTROL_FWD | CONTROL_ML_LBUTTON, TRUE, TRUE);
            llSetTimerEvent(0.1);
        }
    }
    
    control(key owner, integer level, integer edge)
    {
       if(flying)
       { // Look for the jump key going down for the first time.
        if (!(level & CONTROL_FWD))
        {
            llMessageLinked(LINK_SET, FALSE, "stop", "");
                    
            
//..................IDLE...............................
        

vector I_start_color = <1 ,1,1>;
vector I_end_color = <0.5,0,0.2>; 

float I_start_alpha = 0.0; 
float I_end_alpha = 1.0;   

vector I_start_scale = <0.3,0.3,0.0>;   
vector I_end_scale = <0,0,0>;    

float I_particle_age = 1.5;

float I_inner_angle = PI; 
float I_outer_angle = PI; 
vector I_spin_speed = <0.0,0.0,0.0>;   

vector I_particle_accel = <0.0,0.0,0.0>;

float I_burst_rate = 0.1;
integer I_burst_count = 50;
float I_burst_radius = 0.05;
float I_min_speed = 0.1;
float I_max_speed = 0.65;

float I_source_age = 0.0;  // 0.0 = forever

string I_particle_texture = "particle_glowWhite2"; //if not defined, the default particle

key I_target; //the target of your particles if they use a follow mask


        llParticleSystem([
            PSYS_PART_FLAGS, 
                PSYS_PART_INTERP_COLOR_MASK |
                PSYS_PART_INTERP_SCALE_MASK |
              
                PSYS_PART_FOLLOW_SRC_MASK |
                PSYS_PART_FOLLOW_VELOCITY_MASK |
              
                PSYS_PART_EMISSIVE_MASK, 
         
                     
            PSYS_PART_START_COLOR, I_start_color,
            PSYS_PART_END_COLOR, I_end_color,
                     
         
                     
            PSYS_PART_START_SCALE, I_start_scale,
            PSYS_PART_END_SCALE, I_end_scale,
                     
            PSYS_PART_MAX_AGE, I_particle_age,
                     
            
            PSYS_SRC_PATTERN,
                PSYS_SRC_PATTERN_ANGLE_CONE,
            
            PSYS_SRC_INNERANGLE, I_inner_angle,
            PSYS_SRC_OUTERANGLE, I_outer_angle,
            PSYS_SRC_OMEGA, I_spin_speed,
            
            PSYS_SRC_ACCEL,  I_particle_accel,
            
            PSYS_SRC_TEXTURE, I_particle_texture,
            
            PSYS_SRC_BURST_RATE, I_burst_rate,
            PSYS_SRC_BURST_PART_COUNT, I_burst_count,
            PSYS_SRC_BURST_RADIUS, I_burst_radius,
            PSYS_SRC_BURST_SPEED_MIN, I_min_speed,
            PSYS_SRC_BURST_SPEED_MAX, I_max_speed,
            
            PSYS_SRC_MAX_AGE, I_source_age
            ]);
            
        }
        else
        {
            
          llMessageLinked(LINK_SET, TRUE, "burst", ""); 
vector start_color = <1 ,1,1>;
vector end_color = <0.65,0.3,0.0>; 

float start_alpha = 1.0; 
float end_alpha = 0.0; 

vector start_scale = <0.25,0.25,0.0>;
vector end_scale = <0.1,0.1,0.0>;   //scale (z is ignored)

float particle_age = 2.5; 

float inner_angle = PI; 
float outer_angle = PI;  
vector spin_speed = <0.0,0.0,0.0>;
vector particle_accel = <0.0,0.0,0.0>;

float burst_rate = 0.01;   
integer burst_count = 20;
float burst_radius = 0.1;   
float min_speed = 1;      
float max_speed = 1.5;

float source_age = 0.0; //  0.0 = forever

string particle_texture = "particle_glowOrange4";

key target; 


{

    {

        llParticleSystem([
            PSYS_PART_FLAGS, 
                PSYS_PART_INTERP_COLOR_MASK |
                PSYS_PART_INTERP_SCALE_MASK |
                //PSYS_PART_WIND_MASK |
                //PSYS_PART_BOUNCE_MASK |
                PSYS_PART_FOLLOW_SRC_MASK |
                PSYS_PART_FOLLOW_VELOCITY_MASK |
                //PSYS_PART_TARGET_POS_MASK |
                PSYS_PART_EMISSIVE_MASK, 
                //PSYS_PART_TARGET_LINEAR_MASK, 
                     
            PSYS_PART_START_COLOR, start_color,
            PSYS_PART_END_COLOR, end_color,
                     
            PSYS_PART_START_ALPHA, start_alpha,
            PSYS_PART_END_ALPHA, end_alpha,
                     
            PSYS_PART_START_SCALE, start_scale,
            PSYS_PART_END_SCALE, end_scale,
                     
            PSYS_PART_MAX_AGE, particle_age,
                     
            
            PSYS_SRC_PATTERN,
                //PSYS_SRC_PATTERN_DROP,
                //PSYS_SRC_PATTERN_EXPLODE,
                //PSYS_SRC_PATTERN_ANGLE,
                PSYS_SRC_PATTERN_ANGLE_CONE,
            
            PSYS_SRC_INNERANGLE, inner_angle,
            PSYS_SRC_OUTERANGLE, outer_angle,
            PSYS_SRC_OMEGA, spin_speed,
            
           // PSYS_SRC_ACCEL,  particle_accel,
            
            PSYS_SRC_TEXTURE, particle_texture,
            
            PSYS_SRC_BURST_RATE, burst_rate,
            PSYS_SRC_BURST_PART_COUNT, burst_count,
            PSYS_SRC_BURST_RADIUS, burst_radius,
            PSYS_SRC_BURST_SPEED_MIN, min_speed,
            PSYS_SRC_BURST_SPEED_MAX, max_speed,
            
            PSYS_SRC_MAX_AGE, source_age//,
            
            //PSYS_SRC_TARGET_KEY, target
            
            ]);
        
        }}
        
}
            
     
        
    

}   
}
}

 

Andrew Linden's Teacup Flight Script

Expired

// Simple airplane script example

// THIS SCRIPT IS PUBLIC DOMAIN! Do not delete the credits at the top of this script!

// Nov 25, 2003 - created by Andrew Linden and posted in the Second Life scripting forum
// Jan 05, 2004 - Cubey Terra - minor changes: customized controls, added enable/disable physics events
// Feel free to copy, modify, and use this script.
// Mar 02, 2004 - Modified for Illume's Teacup by Oboe Blanc.

// Always give credit to Andrew Linden and all people who modify it in a readme or in the object description.



// assumes that the root primitive is oriented such that its
// local x-axis points toward the nose of the plane, and its
// local z-axis points toward the top

// control flags that we set later
integer gAngularControls = 0;
integer gLinearControls = 0;

// we keep track of angular history for more responsive turns
integer gOldAngularLevel = 0;

// the linear motor uses an accumulator model rather than keeping track
// of the linear control level history
vector gLinearMotor = <0, 0, 0>;

default
{
    state_entry()
    {
        llSetSitText("Fly");
        llCollisionSound("", 0.0);

        // the sit and camera placement is very shape dependent
        // so modify these to suit your vehicle
        llSitTarget(<0.6, 0.0, 0.20>, ZERO_ROTATION);
        llSetCameraEyeOffset(<-10.0, 0.0, 2.0> );
        llSetCameraAtOffset(<3 .0, 0.0, 1.0> );

        llSetVehicleType(VEHICLE_TYPE_AIRPLANE);

        // weak angular deflection
         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.1);
         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 1.0);

        // strong linear deflection
         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1.0);
         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.2);

        // somewhat responsive linear motor
         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.5);
         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 20);

        // somewhat responsive angular motor, but with 3 second decay timescale
         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.5);
         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 3);

        // very weak friction
         //llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000 .0, 1000.0, 1000.0> ); // CUBEY - original line
         llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <200 , 20, 20> ); // CUBEY - increased friction
         llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000 .0, 1000.0, 1000.0> );

         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.65);  // almost wobbly - CUBEY - increased from .25 to improve stability
         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.5);    // mediocre response

         llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.4);    // medium strength
        llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.1);     // very responsive
        llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 0.95);          // more banking when moving

        // hover can be better than sliding along the ground during takeoff and landing
        // but it only works over the terrain (not objects)
        //llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 3.0);
        //llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.5);
        //llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 2.0);
        //llSetVehicleFlags(VEHICLE_FLAG_HOVER_UP_ONLY);

        // non-zero buoyancy helps the airplane stay up
        // set to zero if you don't want this crutch
        llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0.32); //Oboe

        // define these here for convenience later 
        // CUBEY - modified these as per Shadow's prefs
        gAngularControls = CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_BACK | CONTROL_FWD;
        gLinearControls = CONTROL_UP | CONTROL_DOWN;

        llSetStatus(STATUS_PHYSICS, FALSE); //CUBEY - ensure that physics are disabled when plane is rezzed so it doesn't fly off
    }

    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            if (agent)
            {
                if (agent != llGetOwner())
                {
                    // only the owner can use this vehicle
                    llSay(0, "You aren't the owner -- only the owner can fly this plane.");
                    llUnSit(agent);
                    llPushObject(agent, <0,0,10>, ZERO_VECTOR, FALSE);
                }
                else
                {
                    // clear linear motor on successful sit
                    gLinearMotor = <0, 0, 0>;
                     llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);

                    //llSetStatus(STATUS_PHYSICS, TRUE);
                     llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1000.0);
                     llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1000.0);
                    llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
                }
            }
            else
            {
                // stop the motors
                gLinearMotor = <0, 0, 0>;
                 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
                 llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, gLinearMotor);

                // use friction to stop the vehicle rather than pinning it in place
                //llSetStatus(STATUS_PHYSICS, FALSE);
                 llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1.0);
                 llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1.0);

                // driver is getting up
                llReleaseControls();
                llStopAnimation("sit");
                llSetStatus(STATUS_PHYSICS, FALSE); //CUBEY - turn off physics to make sure the parked plane can't be moved
            }
        }

    }

    run_time_permissions(integer perm)
    {
        if (perm)
        {
            llStartAnimation("sit");
            llTakeControls(gAngularControls | gLinearControls, TRUE, FALSE);
            llSetStatus(STATUS_PHYSICS, TRUE); //CUBEY - enable physics when avatar sits
        }
    }

    control(key id, integer level, integer edge)
    {
        // only change linear motor if one of the linear controls are pressed
        vector motor;
        integer motor_changed = level & gLinearControls;
        if (motor_changed)
        {
            if(level & CONTROL_UP) //CUBEY
            {
                if (gLinearMotor.x <0)
                {
                    gLinearMotor.x = 0;
                }
                else if (gLinearMotor.x < 30)
                {
                    gLinearMotor.x += 1; //Oboe
                }
                motor_changed = TRUE;
            }
            if(level & CONTROL_DOWN) //CUBEY
            {
                if (gLinearMotor.x > 0)
                {
                    gLinearMotor.x = 0;
                }
                else if (gLinearMotor.x > -30)
                {
                    gLinearMotor.x -= 1; //Oboe
                };
                motor_changed = TRUE;
            }
             llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
        }

        // only change angular motor if the angular levels have changed
        motor_changed = (edge & gOldAngularLevel) + (level & gAngularControls);
        if (motor_changed)
        {
            motor = <0,0,0>;
            if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
            {
                // add roll component ==> triggers banking behavior
                motor.x += 10;
            }
            if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
            {
                motor.x -= 10;
            }
            if(level & (CONTROL_BACK)) // CUBEY
            {
                // add pitch component ==> causes vehicle lift nose (in local frame)
                motor.y -= 8;
            }
            if(level & (CONTROL_FWD)) // CUBEY
            {
                motor.y += 8;
            }
             llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, motor);
        }
        // store the angular level history for the next control callback
        gOldAngularLevel = level & gAngularControls;
    }
}

 

Andrew Linden's Flight Script

Expired

// Simple airplane script example

// THIS SCRIPT IS PUBLIC DOMAIN! Do not delete the credits at the top of this script!

// Nov 25, 2003 - created by Andrew Linden and posted in the Second Life scripting forum
// Jan 05, 2004 - Cubey Terra - minor changes: customized controls, added enable/disable physics events
// Feel free to copy, modify, and use this script.

// Always give credit to Andrew Linden and all people who modify it in a readme or in the object description.



// assumes that the root primitive is oriented such that its
// local x-axis points toward the nose of the plane, and its
// local z-axis points toward the top

// control flags that we set later
integer gAngularControls = 0;
integer gLinearControls = 0;

// we keep track of angular history for more responsive turns
integer gOldAngularLevel = 0;

// the linear motor uses an accumulator model rather than keeping track
// of the linear control level history
vector gLinearMotor = <0, 0, 0>;

default
{
    state_entry()
    {
        llSetSitText("Fly");
        llCollisionSound("", 0.0);

        // the sit and camera placement is very shape dependent
        // so modify these to suit your vehicle
        llSitTarget(<0.6, 0.0, 0.20>, ZERO_ROTATION);
        llSetCameraEyeOffset(<-10.0, 0.0, 2.0> );
        llSetCameraAtOffset(<3 .0, 0.0, 1.0> );

        llSetVehicleType(VEHICLE_TYPE_AIRPLANE);

        // weak angular deflection
         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.1);
         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 1.0);

        // strong linear deflection
         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1.0);
         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.2);

        // somewhat responsive linear motor
         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.5);
         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 20);

        // somewhat responsive angular motor, but with 3 second decay timescale
         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.5);
         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 3);

        // very weak friction
         //llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000 .0, 1000.0, 1000.0> ); // CUBEY - original line
         llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <200 , 20, 20> ); // CUBEY - increased friction
         llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000 .0, 1000.0, 1000.0> );

         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.65);  // almost wobbly - CUBEY - increased from .25 to improve stability
         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.5);    // mediocre response

         llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.4);    // medium strength
        llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.1);     // very responsive
        llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 0.95);          // more banking when moving

        // hover can be better than sliding along the ground during takeoff and landing
        // but it only works over the terrain (not objects)
        //llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 3.0);
        //llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.5);
        //llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 2.0);
        //llSetVehicleFlags(VEHICLE_FLAG_HOVER_UP_ONLY);

        // non-zero buoyancy helps the airplane stay up
        // set to zero if you don't want this crutch
        llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0.2);

        // define these here for convenience later 
        // CUBEY - modified these as per Shadow's prefs
        gAngularControls = CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_BACK | CONTROL_FWD;
        gLinearControls = CONTROL_UP | CONTROL_DOWN;

        llSetStatus(STATUS_PHYSICS, FALSE); //CUBEY - ensure that physics are disabled when plane is rezzed so it doesn't fly off
    }

    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            if (agent)
            {
                if (agent != llGetOwner())
                {
                    // only the owner can use this vehicle
                    llSay(0, "You aren't the owner -- only the owner can fly this plane.");
                    llUnSit(agent);
                    llPushObject(agent, <0,0,10>, ZERO_VECTOR, FALSE);
                }
                else
                {
                    // clear linear motor on successful sit
                    gLinearMotor = <0, 0, 0>;
                     llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);

                    //llSetStatus(STATUS_PHYSICS, TRUE);
                     llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1000.0);
                     llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1000.0);
                    llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
                }
            }
            else
            {
                // stop the motors
                gLinearMotor = <0, 0, 0>;
                 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
                 llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, gLinearMotor);

                // use friction to stop the vehicle rather than pinning it in place
                //llSetStatus(STATUS_PHYSICS, FALSE);
                 llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1.0);
                 llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1.0);

                // driver is getting up
                llReleaseControls();
                llStopAnimation("sit");
                llSetStatus(STATUS_PHYSICS, FALSE); //CUBEY - turn off physics to make sure the parked plane can't be moved
            }
        }

    }

    run_time_permissions(integer perm)
    {
        if (perm)
        {
            llStartAnimation("sit");
            llTakeControls(gAngularControls | gLinearControls, TRUE, FALSE);
            llSetStatus(STATUS_PHYSICS, TRUE); //CUBEY - enable physics when avatar sits
        }
    }

    control(key id, integer level, integer edge)
    {
        // only change linear motor if one of the linear controls are pressed
        vector motor;
        integer motor_changed = level & gLinearControls;
        if (motor_changed)
        {
            if(level & CONTROL_UP) //CUBEY
            {
                if (gLinearMotor.x <0)
                {
                    gLinearMotor.x = 0;
                }
                else if (gLinearMotor.x < 30)
                {
                    gLinearMotor.x += 5;
                }
                motor_changed = TRUE;
            }
            if(level & CONTROL_DOWN) //CUBEY
            {
                if (gLinearMotor.x > 0)
                {
                    gLinearMotor.x = 0;
                }
                else if (gLinearMotor.x > -30)
                {
                    gLinearMotor.x -= 5;
                };
                motor_changed = TRUE;
            }
             llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
        }

        // only change angular motor if the angular levels have changed
        motor_changed = (edge & gOldAngularLevel) + (level & gAngularControls);
        if (motor_changed)
        {
            motor = <0,0,0>;
            if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
            {
                // add roll component ==> triggers banking behavior
                motor.x += 10;
            }
            if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
            {
                motor.x -= 10;
            }
            if(level & (CONTROL_BACK)) // CUBEY
            {
                // add pitch component ==> causes vehicle lift nose (in local frame)
                motor.y -= 8;
            }
            if(level & (CONTROL_FWD)) // CUBEY
            {
                motor.y += 8;
            }
             llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, motor);
        }
        // store the angular level history for the next control callback
        gOldAngularLevel = level & gAngularControls;
    }
}

 

Command Script

Expired

This is a script that can be used for animated "vehicles" like a horse:

 

// Command
//
// Control script for single link set synchronized animation
// Author: Jesrad Seraph

// This script has the vehicle parameters and the controls event for your mount.
// It calculates the animation step needed after the rider control inputs
// then sends it to the animated parts of the link_set, who each must have a Movement
// script to listen to these messages and move.

// These are the constants you need to change to adapt this script to another beast:
integer max_idle_anims = 1;
integer max_walk_anims = 2;
integer max_run_anims = 4;
integer max_jump_anims = 4;
// Copy these constants in the Movement scripts for the mobile parts of your beast,
// and change the rotations for the steps (the number of rotations in the lists must
// match the max_anims numbers entered above !)

integer RUNNING;
integer FWD;
integer TURNING;
integer IS_JUMPING;

vector fwd_vel = <16 ,0,0>;
vector left_vel = <0,0,-4>;
vector jump_vel = <32 ,0,32>;

integer step;
float timerate = 0.175;

integer chan;
integer max_listeners = 2;
integer ALTERN = 0;

integer roam_state = 0;
vector roam_around;
float roam_range = 8.0;
float follow_range = 200.0;
float roam_delay = 4.0;
key roam_target;

vector PUSH_OFF = <0,9,8>;
vector sit_pos = <0.9,0,0.5>;
vector sit_rot = <0,0,0>;

integer menu_handle;
integer menu_channel;

default
{
    control(key id, integer level, integer edge)
    {
        if(level & CONTROL_FWD)
        {
            FWD = 1;
            llSetStatus(STATUS_PHYSICS, TRUE);
            if (RUNNING > 0)
            {
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, fwd_vel);
            } else {
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, 0.6 * fwd_vel);
            }
        } else if(level & CONTROL_BACK)
        {
            FWD = -1;
            if (RUNNING > 0)
            {
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, -1.0 * fwd_vel);
            } else {
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, -0.4 * fwd_vel);
            }
        } else {
            FWD = 0;
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, ZERO_VECTOR);
        }

        if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
        {
            TURNING = -1;
            if (RUNNING > 0)
            {
                llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, 0.6 * left_vel);
            } else {
                llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, left_vel);
            }
        } else if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
        {
            TURNING = 1;
            if (RUNNING > 0)
            {
                llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, -0.6 * left_vel);
            } else {
                llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, -1.0 * left_vel);
            }
        } else {
            TURNING = 0;
            llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, ZERO_VECTOR);
        }

        if( (level & (CONTROL_UP)) && (edge & (CONTROL_UP)) )
        {
            IS_JUMPING = max_jump_anims;
            llApplyImpulse(jump_vel * llGetMass(), TRUE);
        }

        if( (edge & (CONTROL_DOWN)) && (level & (CONTROL_DOWN)) )
        {
            if (RUNNING == 0)
            {
                llStartAnimation("motorcycle_sit");
                RUNNING = 1;
            } else {
                llStopAnimation("motorcycle_sit");
                RUNNING = 0;
            }
        }
    }

    timer()
    {
        // Steps:
        //
        // gets the next step and sends it along with posible turning parameter

        // all these calculations could be replaced by a sync'd timer in the Movement script...

        integer temp; // anim offset, to save calculations below
        
        if (IS_JUMPING > 0)
        {
            llSetTimerEvent(timerate);
            IS_JUMPING -= 1;
            temp = max_idle_anims + max_walk_anims + max_run_anims;
            if (step = max_idle_anims)
                {
                    // was not idle at last step
                    step = 0;
                } else {
                    // cycling through idle anims
                    step = (step + 1) % max_idle_anims;
                }
            } else {
                llSetTimerEvent(timerate);
    
                if ((RUNNING == 0) || (FWD == 0))
                {
                    // walking animation
    
                    temp = max_idle_anims + max_walk_anims;
                    if ((step = temp))
                    {
                        // was not walking at last step
                        step = max_idle_anims;
                    } else {
                        step = ((step - max_idle_anims + 1) % max_walk_anims) + max_idle_anims;
                    }
                } else {
                    temp = max_idle_anims + max_walk_anims;
                    if((step = temp + max_run_anims))
                    {
                        step = temp;
                    } else {
                        step = ((step - temp + 1) % max_run_anims) + temp;
                    }
                }
            }
        }
        ALTERN = (ALTERN + 1) % max_listeners;
        llSay(chan + ALTERN, (string)step);
    }
    
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            if (agent)
            {
                if (agent != llGetOwner())
                {
                    llUnSit(agent);
                    llPushObject(agent, PUSH_OFF * llGetRot(), ZERO_VECTOR, FALSE);
                    llPlaySound("cui", 1);
                    llSay(0, "Wah!");
                }
                else
                {
                    llSensorRemove();
                    roam_state = 0;
                    llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
                    llCollisionSound("", 0);
                    llPlaySound("wark", 1);
                    llSay(0, "Wark.");
                    llSetStatus(STATUS_PHYSICS, TRUE);
                    llStopLookAt();
                }
            }
            else
            {
                llReleaseControls();
                llStopAnimation("motorcycle_sit");
                llSetStatus(STATUS_PHYSICS, FALSE);
                llPushObject(llGetOwner(), PUSH_OFF, ZERO_VECTOR, TRUE);
                roam_state = 0;
            }
        }
    }

    on_rez(integer a)
    {
        llSleep(1);
        llResetScript();
    }

    state_entry()
    {
        llSetSitText("Ride");
        llSetTouchText("Cuddle");
        llSitTarget(sit_pos, llEuler2Rot(DEG_TO_RAD * sit_rot));

        llSetCameraEyeOffset(<-6.0, 0.0, 2.0>);
        llSetCameraAtOffset(<2 .0, 0.0, 1.0>);

        roam_around = llGetPos();
        roam_target = llGetOwner();

        RUNNING = 0;
        FWD = 0;
        TURNING = 0;
        IS_JUMPING = 0;

        llSetVehicleFlags(-1);
        llSetVehicleType(VEHICLE_TYPE_CAR);

        llRemoveVehicleFlags(VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.8);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.8);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, .1);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, .1);
         
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, .1);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, .1);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, .1);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, .1);
        
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1 .0, .1, 1000.0>);
        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <.1, .1, .1>);
        
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, .8);
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, .1);

        llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.25);
        llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.1);

        chan = (integer)llFrand(200000000) + 54321;
        llMessageLinked(LINK_SET, chan, "defchan", "");
        llSensorRemove();
        llSetTimerEvent(timerate);
    }

    listen(integer chan, string name, key sayer, string msg)
    {
        if (sayer != llGetOwner())
            return;
        llSetText("", ZERO_VECTOR, 0.0);
        if (msg == "Help")
        {
            llGiveInventory(sayer, "Instructions");
        } else if (msg == "Stay here")
        {
            roam_state = 0;
            llSensorRemove();
        } else if (msg == "Wander")
        {
            roam_state = 1;
            roam_around = llGetPos();
            llSensorRepeat("", NULL_KEY, PASSIVE | ACTIVE, roam_range, TWO_PI, roam_delay - llFrand(roam_delay / 2));
        } else if (msg == "Follow me")
        {
            roam_state = 2;
            roam_target = llGetOwner();
            llSensorRepeat("", roam_target, AGENT | ACTIVE, follow_range, TWO_PI, roam_delay - llFrand(roam_delay / 2));
        }
    }

    sensor(integer count)
    {
        vector facing;
        vector dir;
        float dist;
        integer n;
        integer selected;

        if (roam_state == 2)
        {
            // Following, found owner
            dir = llDetectedPos(0) - llGetPos();
            facing = llRot2Euler(llRotBetween(llRot2Fwd(llGetRot()), dir));
            facing.x = 0.0;
            facing.y = 0.0;
            llRotLookAt(llGetRot() * llEuler2Rot(facing), 1.0, 0.2);
            llSleep(0.2);
            dist = llVecMag(dir);
            if (dist > 4.0)
            {
                llSetStatus(STATUS_PHYSICS, TRUE);
                for (selected = llFloor(dist); selected > 1; --selected)
                {
                    llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, 0.5 * fwd_vel);
                    ALTERN = (ALTERN + 1) % max_listeners;
                    llSay(chan + ALTERN, (string)((selected % max_walk_anims) + max_idle_anims));
                    llSleep(timerate);
                }
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, ZERO_VECTOR);
                llSetStatus(STATUS_PHYSICS, FALSE);
            }
            llStopLookAt();
        } else if (roam_state == 1)
        {
            // Wandering, found obstacle
            dist = roam_range + 1;
            // select the closest obstacle
            for(n=0; n 1; --selected)
            {
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, 0.5 * fwd_vel);
                ALTERN = (ALTERN + 1) % max_listeners;
                llSay(chan + ALTERN, (string)((selected % max_walk_anims) + max_idle_anims));
                llSleep(timerate);
            }
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, ZERO_VECTOR);
            llSetStatus(STATUS_PHYSICS, FALSE);
            llStopLookAt();
        }
    }

    no_sensor()
    {
        vector facing;
        vector dir;
        float dist;
        integer selected;

        if (roam_state == 2)
        {
            // Following, did not found owner
            llInstantMessage(llGetOwner(), "HELP I am lost in " + llGetRegionName() + " at " + (string)llGetPos());
            llSetText("I'm a poor, stranded " + llGetObjectName() + " who lost its owner...", <1 ,.7,.4>, 1.0);
            llSensorRemove();
        } else if (roam_state == 1)
        {
            // Wandering, no obstacles
            facing.x = 0.0;
            facing.y = 0.0;
            facing.z = llFrand(TWO_PI) - PI;
            dir = (((llCeil(llGetTime()) % llCeil(roam_range)) + 1) * facing) * llGetRot();
            llRotLookAt(llGetRot() * llEuler2Rot(facing), 1.0, 0.2);
            llSleep(0.2);
            dist = llVecMag(dir);
            if (dist <1.0)
            {
                dir = roam_around - llGetPos();
            }
            llSetStatus(STATUS_PHYSICS, TRUE);
            for (selected = llFloor(dist); selected > 1; --selected)
            {
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, fwd_vel);
                ALTERN = (ALTERN + 1) % max_listeners;
                llSay(chan + ALTERN, (string)((selected % max_run_anims) + max_idle_anims + max_walk_anims) );
                llSleep(timerate);
            }
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, ZERO_VECTOR);
            llSetStatus(STATUS_PHYSICS, FALSE);
            llStopLookAt();
        }
    }

    touch_start(integer a)
    {
        if (llDetectedType(0) == AGENT | ACTIVE)
        {
            if (llDetectedKey(0) == llGetOwner())
            {
                llPlaySound("wark", 1);
                llSay(0, "Wark!");
                llListenRemove(menu_handle);
                menu_channel = (integer)llFrand(2000000)+1234;
                menu_handle = llListen(menu_channel, "", "", "");
                llDialog(llDetectedKey(0), "Tell " + llGetObjectName() + " to:", ["Stay here", "Wander", "Follow me", "Help"], menu_channel);
            } else {
                llPlaySound("cui", 1);
                llSay(0, "WAH!");
            }
        }
    }
    
    run_time_permissions(integer perm)
    {
        if (perm)
        {
            llTakeControls(    CONTROL_FWD |
                    CONTROL_BACK |
                    CONTROL_RIGHT |
                    CONTROL_LEFT |
                    CONTROL_ROT_RIGHT |
                    CONTROL_ROT_LEFT |
                    CONTROL_UP |
                    CONTROL_DOWN, TRUE, FALSE);
        }
    }
}