Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Okay. That does it. I give up!

Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
07-18-2005 09:01
Kwipper's Mouselook Motorcycle Script


CODE

default
{
state_entry()
{
// what the pie menu says if you want to get in
llSetSitText("Ride");

// hearing collision sounds when on the ground would suck, so we mute them.
llCollisionSound("", 0.0);

// where the AV sits (this assumes that the root prim is the drivers seat)
llSitTarget(<0.6, 0.05, 0.20>, ZERO_ROTATION);

// readjust the camera so the driver can see
llSetCameraEyeOffset(<-5.0, 0.0, 2.0>);
llSetCameraAtOffset(<3.0, 0.0, 2.0>);

// resets the vehicle flags
llSetVehicleFlags(-1);

// define the vehicle as a vehicle and what kind it will be
// possibilities inclide:
// VEHICLE_TYPE_SLED
// VEHICLE_TYPE_CAR
// VEHICLE_TYPE_BOAT
// VEHICLE_TYPE_AIRPLANE
// VEHICLE_TYPE_BALLOON
llSetVehicleType(VEHICLE_TYPE_CAR);

// flags to set special attributes or behaiviors to the craft
// VEHICLE_FLAG_NO_DEFLECTION_UP Prevents linear deflection parallel to the
// world-z axis. or in plain english linear deflection will not push up
// VEHICLE_FLAG_LIMIT_ROLL_ONLY Removes vertical attraction for changes in
// vehicle pitch allows craft that use vertical attraction to nose up/down
// VEHICLE_FLAG_HOVER_WATER_ONLY Hover only pays attention to water level
// hover keeps craft at a fixed height above the water height (ignoring terrain height)
// VEHICLE_FLAG_HOVER_TERRAIN_ONLY Hover only pays attention to terrain height
// hover keeps craft at a fixed height above the terrain height (ignoring water height)
// VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT Hover only pays attention to global height
// hover at global altitude ignoring terrain and water levels
// VEHICLE_FLAG_HOVER_UP_ONLY Hover only pushes up
// hover will not push down, hover height will be the lowest the craft can go
// VEHICLE_FLAG_LIMIT_MOTOR_UP Prevents ground vehicles from motoring into the sky
// keeps ground craft from flying up or steering midair
//
// VEHICLE_FLAG_MOUSELOOK_STEER Makes vehicle try to turn toward mouselook direction
// VEHICLE_FLAG_MOUSELOOK_BANK Makes vehicle try to turn toward mouselook
// direction assuming banking is enabled
// VEHICLE_FLAG_CAMERA_DECOUPLED Causes the camera look-at axis to NOT
// move when the vehicle rotates

// flags we are not applying to this craft.
// may be unneccessary unless craft will change flags when entering different modes
// but seems like a good idea o have them anyway. if the craft will change modes
// i.e. enter a staet to be a car not an airplane then you would remove the airplane
// type flags and add car type ones.
llRemoveVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP
| VEHICLE_FLAG_HOVER_WATER_ONLY
| VEHICLE_FLAG_HOVER_TERRAIN_ONLY
| VEHICLE_FLAG_LIMIT_MOTOR_UP
| VEHICLE_FLAG_LIMIT_ROLL_ONLY
| VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT
| VEHICLE_FLAG_HOVER_UP_ONLY);

// flags we are applying to this craft
llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP
| VEHICLE_FLAG_LIMIT_MOTOR_UP
| VEHICLE_FLAG_LIMIT_ROLL_ONLY
| VEHICLE_FLAG_MOUSELOOK_STEER
| VEHICLE_FLAG_MOUSELOOK_BANK
// | VEHICLE_FLAG_CAMERA_DECOUPLED
);

// no deflection = (0.0) max deflection = 1.0
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.00);

// no deflection = (0.0) max deflection = 1.0
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1.0);

// angular deflection: an outside push will attempt to reorient craft
// to match direction of push.
// i.e. a collision from the side will turn the craft to point
// the same direction as the impact was going.
// time till craft twists to match direction of outside push
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.06);

// linear deflection: any push from any angle will attempt to be
// redirected along the axis that the craft wishes to go (forward)
// i.e. a car will want to go in the direction its wheels are facing
// time till craft moves in direction of outside push
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.06);

// the time it takes to reach top speed min = 0.06
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 2.0);

// time during which the motor's effectiveness exponentially decays max = 120
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 1.0);

// the time it takes to be spinning at full speed. min = 0.06
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.06);

// time during which the spin exponentially decays max = 120
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 120);

// linear friction: friction on a straight line x,y,z planes.
// or how long it will take to stop moving on each axis
// (not a measure of time as far as i can tell).
// higher numbers give less friction. max value = 1000 Default: <1000.0, 2.0, 1000.0>
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000.0, 2.0, 2.0>);

// angular friction: resistance to turning
// or how easy it is to twist, and how long it will take to level off
// (not a measure of time as far as i can tell).
// higher numbers give less friction. max value = 1000 Default: <10.0, 10.0, 1000.0>
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000.0, 10.0, 1000.0>);

// min = 0.0 = wobbly max = 1.0 = steady
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.50);

// vertical attraction: keeps the top side up
// higher numbers = more degree of bank
// lower numbers = less degree of bank
// i.e. the x axis of the craft is locked to the world x axis
// set above 300 to disable
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.45);

// * Note that by default the vertical attractor will prevent the craft
// * from diving and climbing. So, if you wanted to make a airplane you
// * would probably want to set the VEHICLE_FLAG_LIMIT_ROLL_ONLY flag
// * to allow pitch (nose up/down)

// amount of lean during turns
// min = -1 lean out of turns max = 1 lean into turns (Default: 1)
llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 1);

// time to reach the full tilt of the banking
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.00);

// min = 0 = static max = 1 = dynamic
// i have no clear idea what this does, in some way it effects
// the craft banking while stopped and moving
llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 1) ;
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{
if (agent != llGetOwner())
{
llSay(0, "You aren't the owner");
llUnSit(agent);
llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
}
else
{
llSetStatus(STATUS_PHYSICS, TRUE);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
}
else
{
llSetStatus(STATUS_PHYSICS, FALSE);
llReleaseControls();
llStopAnimation("motorcycle_sit");
}
}
}
run_time_permissions(integer perm)
{
if (perm)
{
llStartAnimation("motorcycle_sit");
llTakeControls(CONTROL_FWD | CONTROL_DOWN | CONTROL_UP | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
}
}
control(key id, integer level, integer edge)
{
vector angular_motor;

if(level & CONTROL_FWD)
{
//linear motor: as motor implies the push that makes your craft go
// the linear velocity that the craft attempt to achieve. max = 40
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <40,0,0>);
}
if(level & CONTROL_BACK)
{
//linear motor: as motor implies the push that makes your craft go
// the linear velocity that the craft attempt to achieve. max = -40
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <-20,0,0>);
}
// if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
// {
// angular_motor.x += 4*PI;
// angular_motor.z -= 4*PI;
// }
// if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
// {
// angular_motor.x -= 4*PI;
// angular_motor.z += 4*PI;
// }
// if(level & (CONTROL_UP))
// {
// angular_motor.y -= 50;
// }
// if(level & (CONTROL_DOWN))
// {
// angular_motor.y += 50;
// }
// angular velocity (radians/sec) that the vehicle will try to rotate.
// max = 4*PI (2 revolutions/sec)
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <4*PI, 4*PI, 4*PI>);
}

}
Frans Charming
You only need one Frans
Join date: 28 Jan 2005
Posts: 1,847
07-18-2005 09:20
I have never made a vehicle script. But it seem to me that you are only letting your scripting respond to CONTROL_FWD and CONTROL_BACK.
You need a CONTROL_LEFT and CONTROL_RIGHT in there.
_____________________
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
07-18-2005 09:27
From: Frans Charming
I have never made a vehicle script. But it seem to me that you are only letting your scripting respond to CONTROL_FWD and CONTROL_BACK.
You need a CONTROL_LEFT and CONTROL_RIGHT in there.
It's mouselook, left and right are handled my the mouse.
Though, they would be good for throttle, or effects...
_____________________
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
07-18-2005 09:41
Well, I made those changes, but still.. No go. BTW. I AM updating the code changes here as well. So you can see my current progress.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
07-18-2005 09:59
*grumbles* let me see if i can dig out my mouselook spinner script, i know that banked. Don't know if the mod will work in a motorcycle
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
07-18-2005 10:22
CODE
default
{
state_entry()
{
llSetSitText("Ride");
llSitTarget(<0.6, 0.05, 0.20>, ZERO_ROTATION);
llSetCameraEyeOffset(<-5.0, 0.0, 2.0>);
llSetCameraAtOffset(<3.0, 0.0, 0.0>);
llSetVehicleFlags(-1);
llSetVehicleType(VEHICLE_TYPE_CAR);
llSetVehicleFlags(VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_MOUSELOOK_STEER | VEHICLE_FLAG_CAMERA_DECOUPLED );

// Notes for Reference

// X-Axis = Forward & Backward
// Y-Axis = Left & Right
// Z-Axis = Up & Down

//The Linear Engine (Engine for Acceleration)
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1); // A slider between 0 = No Deflection, 1 = Maximum Strength
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.1); // A slider that adjusts how long the vehicle will take to redirect itself along it's X-Axis
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0); // This adjusts how quickly the vehicle accelerates. (0 = fast acceleration, 30 = slowest acceleration.
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.2); // This adjusts how long the vehicle will take to stop when you let off of the acceleration.
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10.0, 0.5, 1000.0>); //This adjusts the friction. (0 = max friction, 17 = no friction)

//The Angular Engine (Engine for Turning)
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0); // This adjusts how well the vehicle turns while accelerating. (0 = sharp turns, 1 = wide turns) (Default = 0.30)
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.1);

llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.01);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 300.0); // Commented out since it has no purpose for mouselook controls. Not true. It's all about intensity

llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <0.0, 0.0, 0.0>); //This adjusts the friction. (0 = max friction, 17 = no friction)

// Stabilization

llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5); // This adjusts how efficient the vehicle stabilizes itself.
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.75); // How long will it take for the vehicle to stablize itself vertically

//Banking

llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, -1.0);
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.10);
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{
if (agent != llGetOwner())
{
llSay(0, "You aren't the owner");
llUnSit(agent);
llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
}
else
{
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0.0,0.0,4.0>);
llSetStatus(STATUS_PHYSICS, TRUE);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
}
else
{
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, ZERO_VECTOR);
llSetStatus(STATUS_PHYSICS, FALSE);
llReleaseControls();
llStopAnimation("motorcycle_sit");
}
}

}

run_time_permissions(integer perm)
{
if (perm)
{
llStartAnimation("motorcycle_sit");
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_ML_LBUTTON, TRUE, FALSE);
}
}

control(key id, integer level, integer edge)
{
if(level & CONTROL_FWD)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <35,0,0>);
}
if(level & CONTROL_BACK)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <-20,0,0>);
}
}
}


_____________________
Frans Charming
You only need one Frans
Join date: 28 Jan 2005
Posts: 1,847
07-18-2005 13:38
From: Jillian Callahan
It's mouselook, left and right are handled my the mouse.
Though, they would be good for throttle, or effects...

lol, that's true.
_____________________
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
07-18-2005 17:52
Okay. I have made some more changes to my script. Please check it out and leave comments or suggestions. THis is my first script. I cannot do this on my own you guys. So I need a LOT of help on this one.
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
07-18-2005 18:03
Ooooh.
I'll go ahead and adapt this to my FreakRockets when I can. First I need to fix the nasty sit-animations bugs.
Meatwad Extraordinaire
Nomnomnom
Join date: 6 Aug 2004
Posts: 545
07-18-2005 18:42
From: Kwipper Manimal
Okay. I have made some more changes to my script. Please check it out and leave comments or suggestions. THis is my first script. I cannot do this on my own you guys. So I need a LOT of help on this one.

If this is your FIRST script, then you should try small things like a door or a taster with some toast... mmmm... Although, if you mean it is your first major script, then you might want to try something different. Vehicles are one of the harder things to do. I'm a pretty good scripter and even I have trouble with vehicles. Try this site if you haven't seen it yet... https://secondlife.com/badgeo/wakka.php?wakka=HomePage Best of luck!
_____________________
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
07-18-2005 18:54
What can I say. I like to start big. BTW. I made some more tweaks on the script and updated it on the first post.