Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

My Hoverboat of Woe.

CoCoNoNo Anubis
Skylark Mechanic
Join date: 28 Jun 2004
Posts: 40
07-08-2004 19:52
I was working on this script for the hoverboat and now it refuses to do anything. It gives the PERMISSION_TRIGGER_ANIMATION error output thingy...

any hints?
_____________________
-CoCoNoNo
Current Major Projects:
CoCoHoBo - Personal conveyance not for the faint of heart.
Dreamer Class Skyships - Personalized skycraft for small parties or gatherings.
CoCoNoNo Anubis
Skylark Mechanic
Join date: 28 Jun 2004
Posts: 40
07-08-2004 19:53
also here is my code for those of you that wanna look at it....I did it mostly by hand so I may have missed something important.

CODE

//the CoCoHoBoat Script
//by CoCoNoNo who shamelessly pillaged the Linden scripting guide and sample scripts.
//its a hoverboat...for all those garden parties sans the garden

//constants
float SPEED=30;
float TIMER_DELAY = 0.2;

//more crap to weed out
float SIT_DROP = 0.15; // Looks cool when you jump on
float ROTATION_RATE = 5.0; // Rate of turning
float JUMP_FORCE = 75.0;
float JUMP_ROTATE = 50.0; // Force to rotate on jump
float JUMP_PITCH = 7.0; // Force to pitch nose upward during a jump
float THRUST_PITCH = 3.0; // Force to pitch nose upward on thrusting fwd/back
float LAND_ROTATE = 15.0; // Nose tips on landing
float PRE_JUMP = 0.5; // How far to come down when readying for jump
float MAX_JUMP_TIME = 2.0; // Max secs to accumulate energy for jump
float FWD_THRUST = 60.0; // Forward thrust motor force
float BACK_THRUST = 30.0; // Backup thrust
float FOLLOW_SCALE = 10.0; // Extra boost to push upward for upcoming hills
float FOLLOW_THRESHOLD = 0.35; // Threshold for when to apply extra force
float AUTO_JUMP_THRESHOLD = 5.0;
float STUMBLE = -1.0; // Z-vel on landing that triggers stumble

float TRICK_RATE = 15.0;

vector PUSH_OFF = <0, 25, 75>;
float MAX_JUMP_DURATION = 15.0; // Jumps longer than this will be ended (like if you land on a house!)

vector LINEAR_FRICTION_RIDE = <10.0, 5.0, 1000.0>; // Friction while riding
vector LINEAR_FRICTION_BRAKE = <0.5, 0.5, 1000.0>; // Friction while braking


//instance vars
float hover_height=20;
integer onward_ho=FALSE;
key avatar;

//need to weed this crap
float jump_timer = 0.0;
float height_agl = 0.0;
float ground_height = 0.0;
float water_height = 0.0;
integer timer_count = 0;
vector pos;
vector vel;
rotation rot;
float vel_mag;
float follow_diff;
float cur_time;

integer is_jumping = FALSE;

integer over_water = FALSE;

default
{
state_entry()
{
llSetVehicleType(VEHICLE_TYPE_BOAT);
llSitTarget(<0.0, 0.0, 0.0>, <0,90,0,1>); // Set seating location. Change for different height AVs

//its big and pudgy...not a fighter skiff.
llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <3, 3, 3> );

//helps make it hard to turn on any of the axis
llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1.5 );

//quick to go, hard to stop
llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 2.5 );
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 5 );

//kinda hard to turn and overshoots a little
llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 4 );
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 6 );

//rises and falls smoothly
llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, hover_height );
llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 1 );
llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 2.0 );
llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1 );

// halfway linear deflection with timescale of 3 seconds
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 );
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 3 );

// angular deflection
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.5 );
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5 );

// somewhat bounscy vertical attractor
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5 );
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 5 );

// weak negative damped banking
llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, -0.3 );
llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.8 );
llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 1 );

// default rotation of local frame
llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );

// remove these flags
llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_TERRAIN_ONLY| VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);

// set these flags
llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP| VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT| VEHICLE_FLAG_LIMIT_MOTOR_UP| VEHICLE_FLAG_LIMIT_ROLL_ONLY );

llSetSitText("sail!");
//llSetTimerEvent(TIMER_DELAY);
}

touch_start(integer num)
{
if(llDetectedKey(0) != llGetOwner())
{
llWhisper(0, "not for sale.");
}
else
{
llWhisper(0, "you know you wanna ride this boat.");
}
}

changed(integer change)
{
avatar = llAvatarOnSitTarget();

if(change & CHANGED_LINK)
{
if(avatar == NULL_KEY)
{
//
//leaving the con, stand up...
//
llMessageLinked(LINK_SET, 0, "idle", "");
llSetStatus(STATUS_PHYSICS, FALSE);
llReleaseControls();
llStopAnimation("sit");

//llSetTimerEvent(0.0);
}
else if(avatar == llGetOwner())
{
//
// boatin time!!
//
//llMessageLinked(LINK_SET, 0, "get_on", "");
llSetStatus(STATUS_PHYSICS | STATUS_BLOCK_GRAB, TRUE);
llRequestPermissions(avatar, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
//llSetTimerEvent(TIMER_DELAY);
}
else
{
llSay(0, "Buy your own, STUPID.");
llUnSit(avatar);
}
}
}

//sits the AV down, and hands the controls over to the script.
run_time_permissions(integer perms)
{
if(perms & (PERMISSION_TAKE_CONTROLS))
{
llStartAnimation("sit");
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
llSleep(0.5);
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hover_height);
}
else
{
llUnSit(avatar);
}
}

//controls
//stolen from the CoCoHoBo by CoCoNoNo who stole (but reasonably modified) them the lindens.
control(key id, integer level, integer edge)
{
//go forward
//tap once and it keeps going onward.
if (level & CONTROL_FWD)
{
//does nothing
if (onward_ho == TRUE)
{
llSay(0, "course laid in, skipper");
}
//goes...set the friction to zero so the boat just slides along
else
{
llSay(0,"full speed ahead!");
onward_ho=TRUE;
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <9999, 3, 3>);
}
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <SPEED,0,0>);
}
//go backward
//if headed forward already, will bring boat to all stop
if (level & CONTROL_BACK)
{
if (onward_ho == FALSE)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <-SPEED,0,0>);
}
else
{
llSay(0, "All Stop!");
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <3, 3, 3>);
onward_ho=FALSE;
}
}
//turn left
if ((level & CONTROL_LEFT) || (level & CONTROL_ROT_LEFT))
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,SPEED,0>);
}
//turn right
if ((level & CONTROL_RIGHT) || (level & CONTROL_ROT_RIGHT))
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,-SPEED,0>);
}
//hover up
if (level & CONTROL_UP)
{
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hover_height+5);
}
//hoverdown
if (level & CONTROL_DOWN)
{
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hover_height - 5);
}
//all stop
}



}
_____________________
-CoCoNoNo
Current Major Projects:
CoCoHoBo - Personal conveyance not for the faint of heart.
Dreamer Class Skyships - Personalized skycraft for small parties or gatherings.
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
07-09-2004 10:59
In your changed() event:
llRequestPermissions(avatar, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);

In your run_time_permissions() event:
if(perms & (PERMISSION_TAKE_CONTROLS)) {
llStartAnimation("sit";);
...



You need to check that PERMISSION_TRIGGER_ANIMATION has been granted as well as PERMISSION_TAKE_CONTROLS before attempting any animations.

Try changing the first line in your run_time_permissions() event to:
if (perms & (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)) {

(I believe... I have not tested this.)
_____________________
Apotheus Silverman
Shop SL on the web - SLExchange.com

Visit Abbotts Aerodrome for gobs of flying fun.