Jetpack

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
 
            ]);
 
        }}
 
}
 
}
}
}

 

Hovercraft

Expired

float LINEAR_TAU = 0.75;
float TARGET_INCREMENT = 0.5;
float ANGULAR_TAU = 1.5;
float ANGULAR_DAMPING = 0.85;
float THETA_INCREMENT = 10;// 0.3
integer LEVELS = 0;
vector pos;
vector face;
float brake = 0.5;
key gOwnerKey;
string gOwnerName;
key gToucher;
key Driver;
string Name1 = "Illume Skallagrimson";
string Name2 = "Chimera Lily";
string gFLYING = "FALSE";
string sound="power";
key id;
integer nudge = FALSE;
vector POSITION;
integer auto=FALSE;
 
help()
{
    llWhisper(0,"Commands:");
    llWhisper(0,"Left click craft = Start ");
    llWhisper(0,"Left click craft = Stop and release contol");
    llWhisper(0,"1! through 9!, slow or warp = Set power");
    llWhisper(0,"view! = Align view to craft");
    llWhisper(0,"menu = Display options");
    llWhisper(0,"PgUp or PgDn = Gain or lose altitude");
    llWhisper(0,"Arrow keys = Left, right, forwards and back");
    llWhisper(0,"Shift + arrow Left, Right = Rotate but maintain view");
    llWhisper(0,"PgUp + PgDn = Set cruise on or off");
}
 
default
{
    state_entry()
    {
 
        gOwnerKey = llGetOwner();
        gOwnerName = llKey2Name(llGetOwner());
        llSoundPreload(sound);
        llStopSound();
        llSetTimerEvent(0.0);
        llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", id);
        llSetStatus(STATUS_PHYSICS, FALSE);
        llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, TRUE);
        llSleep(0.1);
        llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
        llSetStatus(STATUS_PHYSICS, TRUE);
        llMoveToTarget(llGetPos(), 0);
        llRotLookAt(llGetRot(), 0, 0);
        llSetStatus(STATUS_PHYSICS, FALSE);
        LEVELS = CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ML_LBUTTON;
 
        TARGET_INCREMENT = 0.5;
        llSitTarget(<-0.8, 0.0, 1.0>, ZERO_ROTATION);
        llSetCameraEyeOffset(<-10.0, 1.0, 3.0>);
        llSetSitText("Get in");
        llSetCameraAtOffset(<0, 1.0, 0>);
        llWhisper(0,"By your command ... click again to engage. Type menu for options.");
 
        //  this sets a Listen with no callback in this state...
        llListen(0, "", "", "");
 
        state Listening;
    }
 
}
 
state Listening
{
    //  Here we set up the Listen that is used in the Listening state...
    state_entry()
    {
        llListen(0, "", "", "");
    }
 
    // the rest was here before...
    //  This is the click callback
    touch_start(integer total_number)
    {
        if (llSameGroup(llDetectedKey(total_number - 1))==1 || llDetectedName(total_number - 1)==Name1 || llDetectedName(total_number - 1)==Name2)
        {
            if (gFLYING == "FALSE")
            {
                gFLYING = "TRUE";
                llSetStatus(STATUS_PHYSICS, TRUE);
                Driver=llDetectedKey(total_number - 1);
                state StateDriving;
            }
        }
        else
        {
            llWhisper(0,"You must own or belong to this group to fly craft");
            llInstantMessage(gOwnerKey,llDetectedName(total_number - 1) + " is touching your craft");
        }
    }  
 
    //  Here is the Listen callback
    listen(integer chan, string name, key id, string msg)
    {
        if (llSameGroup(id)==1)
        {
            if (llToLower(msg) == "menu")
            {
                help();
            }
        }
    }
 
    //  and this is an on-rez callback
    on_rez(integer start_param)
    {
        llResetScript();
    }
}
 
state StateDriving
{
    state_entry()
    {
        llWhisper(0, "All systems go !!");
        llRequestPermissions(Driver, PERMISSION_TAKE_CONTROLS);
        llMoveToTarget(llGetPos(), LINEAR_TAU);
        llRotLookAt(llGetRot(), ANGULAR_TAU, 1.0);
 
        //  Added listen here as well....  for same reason...
        llListen(0, "", "", "");
    }
 
    touch_start(integer total_number)
    {
        if (llDetectedKey(total_number - 1)==Driver)
        {
            llWhisper(0,"Controls back to you");
            gFLYING = "FALSE";
            auto=FALSE;
            llSleep(1.5);
            llSetStatus(STATUS_PHYSICS, FALSE);
            llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", id);
            llSetTimerEvent(0.0);
            llReleaseControls();
            llResetScript();
        }
    }
 
    listen(integer chan, string name, key id, string msg)
    {
        if (id==Driver)
        {
            if (llToLower(msg) == "view!")
            {
                llReleaseControls();
                llRequestPermissions(Driver, PERMISSION_TAKE_CONTROLS);
            }
            if (llToLower(msg) == "menu")
            {
                help();
            }
            if (llToLower(msg) == "warp")
            {
                TARGET_INCREMENT = 10.0;
                string TIspew = (string)TARGET_INCREMENT;
                TIspew = llGetSubString(TIspew,0,3);
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "slow")
            {
                TARGET_INCREMENT = 0.5;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "1!")
            {
                TARGET_INCREMENT = 0.75;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "2!")
            {
                TARGET_INCREMENT = 1.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "3!")
            {
                TARGET_INCREMENT = 1.5;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "4!")
            {
                TARGET_INCREMENT = 2.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "5!")
            {
                TARGET_INCREMENT = 3.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "6!")
            {
                TARGET_INCREMENT = 4.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "7!")
            {
                TARGET_INCREMENT = 5.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "8!")
            {
                TARGET_INCREMENT = 6.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
            if (llToLower(msg) == "9!")
            {
                TARGET_INCREMENT = 7.0;
                llWhisper(0,"Power: " + llGetSubString((string)TARGET_INCREMENT,0,3));
            }
        }
    }
 
    run_time_permissions(integer perm)
    {
        if (perm == PERMISSION_TAKE_CONTROLS)
        {
            llMessageLinked(LINK_ALL_CHILDREN, 0, "slow", id);
            llPlaySound(sound,0.3);
            llTakeControls(LEVELS, TRUE, FALSE);
 
        }
        else
        {
            llWhisper(0,"Stopped");
            llSetTimerEvent(0.0);
            gFLYING = "FALSE";
            llSleep(1.5);
            llResetScript();
        }
    }
    control(key driver, integer levels, integer edges)
    {
        pos *= brake;
        face.x *= brake;
        face.z *= brake;
        nudge = FALSE;
        llMessageLinked(LINK_ALL_CHILDREN, 0, "slow", id);
        if (levels & CONTROL_FWD)
        {
            if (pos.x <0) { pos.x=0; }
            else { pos.x += TARGET_INCREMENT; }
            nudge = TRUE;
        }
        if (levels & CONTROL_BACK)
        {
            if (pos.x > 0) { pos.x=0; }
            else { pos.x -= TARGET_INCREMENT; }
            nudge = TRUE;
        }
        if (levels & CONTROL_UP)
        {
            llMessageLinked(LINK_ALL_CHILDREN, 0, "fast", id);
            llPlaySound(sound,0.3);
            if(pos.z<0) { pos.z=0; }
            else { pos.z += TARGET_INCREMENT; }
            face.x=0;
            nudge = TRUE;
        }
        if (levels & CONTROL_DOWN)
        {
            llMessageLinked(LINK_ALL_CHILDREN, 0, "fast", id);
            llPlaySound(sound,0.2);
            if(pos.z>0) { pos.z=0; }
            else { pos.z -= TARGET_INCREMENT; }
            face.x=0;
            nudge = TRUE;
        }
        if ((levels) & (CONTROL_LEFT|CONTROL_ROT_LEFT))
        {
            if (face.z <0) { face.z=0; }
            else { face.z += THETA_INCREMENT; }
            nudge = TRUE;
        }
        if ((levels) & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
        {
            if (face.z > 0) { face.z=0; }
            else { face.z -= THETA_INCREMENT; }
            nudge = TRUE;
        }
        if ((levels & CONTROL_UP) && (levels & CONTROL_DOWN))
        {
            if (auto)
            {
                auto=FALSE;
                llWhisper(0,"Cruise off");
                llSetTimerEvent(0.0);
            }
            else
            {
                auto=TRUE;
                llWhisper(0,"Cruise on");
                llSetTimerEvent(0.5);
            }
            llSleep(0.5);
        }
 
        if (nudge)
        {
            vector world_target = pos * llGetRot();
            llMoveToTarget(llGetPos() + world_target, LINEAR_TAU);
 
            vector eul = face;
            eul *= DEG_TO_RAD;
            rotation quat = llEuler2Rot( eul );
            rotation rot = quat * llGetRot();
            llRotLookAt(rot, ANGULAR_TAU, ANGULAR_DAMPING);
        }
    }
 
    timer()
    {
        pos *= brake;
        if (pos.x <0) { pos.x=0; }
        else { pos.x += TARGET_INCREMENT; }
        vector world_target = pos * llGetRot();
        llMoveToTarget(llGetPos() + world_target, LINEAR_TAU);
    }
 
}

 

Speedometer

Expired

float KPH_TO_MPH = 01.631;
 
default
{
    state_entry()
    {
        llSetTimerEvent(.2);
    }
 
    timer()
    {
        float speed = llVecMag(llGetVel())*60*60/1000;
        speed *= KPH_TO_MPH;
        if(speed > 130)
            speed = 130+llFrand(5.0);
        float ratio;
        if(speed <20)
            ratio = speed/240;
        else
            ratio = (speed-10)/120;
        llRotateTexture((ratio*-290)*DEG_TO_RAD, ALL_SIDES);
    }
}