Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Noob needs help: flight

Naismith Miles
Registered User
Join date: 22 Mar 2007
Posts: 4
04-23-2007 07:22
Everyone,
I've been trying to create a hover-jet type script for weeks now. I have read the bejezus out of the wiki and everything else I can find, and I have created a new script that is very similar to the hover-jet script found in a bunch of objects.

Mine doesn't work, and I can't figure out WHY!

I don't get any errors, my AV sits on the target, and the camera slews, but the bloody craft won't BUDGE.

What am I doing wrong?
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
04-23-2007 07:28
Without seeing the script, it's highly unlikely that anyone can help.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Is the fuel on? battery charged? Ignition keys in?
04-23-2007 07:56
As Sys suggested its a bit of an impossible task to debug a script you can't even read.
However a few basic debugging ideas which may help:

The "slap myself silly" things to check :
I apologise now if what I say is stating the bleeding obvious but you will be suprised how often its over looked

Is the script set to running? SL has a tendancy to reset this after a compilation error and it has to be manually reset.

Are you on script enabled land?

If the above are OK then try the following:
Does the script respond in anyway when activated?
Try using llOwnerSay to output debug information as the script runs.
Have you compared the flow of control and data through your own script and the presumably working on? You may find a a seemingly subtle difference can have far reaching effects.
Naismith Miles
Registered User
Join date: 22 Mar 2007
Posts: 4
The script
04-23-2007 08:14
Here is the offending script. I am on script enabled land, and the running check box is marked. I've tried just using a public domain script in the object, and that doesn't work either. No errors show in the error window. The machine has 26 prims linked, so that is ok too.

Thanks everyone.



key pilot;
vector pos;
vector linear;
vector angular;
integer under_power;
integer listenindex;
float throttle;

default
{
state_entry()
{
llWhisper(0, "Ready";);
linear = ZERO_VECTOR;
angular = ZERO_VECTOR;
under_power = FALSE;
throttle = 0.0;
llSetCameraEyeOffset(<-8.0, -3, 0>;);
llSetCameraAtOffset(<0.0, 0.0, 0>;);
llSetVehicleType(VEHICLE_TYPE_AIRPLANE);
llSetSitText("Let's Go!";);
// linear friction
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <100.0, 100.0, 100.0>;);

// uniform angular friction
llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1.0);

// linear motor
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0.0, 0.0, 0.0>;);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 1.0);

// angular motor
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0.0, 0.0, 0.0>;);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 2.0);

// hover
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0.0);
llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.0);
llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 360.0);
llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0.981);

// linear deflection
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1.0);

// angular deflection
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.25);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 100.0);

// vertical attractor
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.75);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.0);

// banking
llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.0);
llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 1.0);
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 360.0);

// default rotation of local frame
llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0.0, 0.00000, 0.00000, 1.0>;);

// removed vehicle flags
llRemoveVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY);

// set vehicle flags
llSetVehicleFlags(VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
}
on_rez(integer sparam)
{
llResetScript();
}
link_message(integer sender, integer num, string str, key id)
{
if (str == "pilot" && id != NULL_KEY) {
linear = ZERO_VECTOR;
angular = ZERO_VECTOR;
under_power = FALSE;
throttle = 0.0;
llRequestPermissions(id, PERMISSION_TAKE_CONTROLS);
llMessageLinked(LINK_SET, 0, "hover", NULL_KEY);
pilot = id;
llListenRemove(listenindex);
listenindex = llListen(0, "", pilot, "";);
} else if (str == "pilot" && id == NULL_KEY) {
llSetStatus(STATUS_PHYSICS, FALSE);
llListenRemove(listenindex);
pilot = NULL_KEY;
llReleaseControls();
}
}

run_time_permissions(integer permissions)
{
if (permissions & PERMISSION_TAKE_CONTROLS) {
llTakeControls( CONTROL_FWD |
CONTROL_BACK |
CONTROL_LEFT |
CONTROL_RIGHT |
CONTROL_ROT_LEFT |
CONTROL_ROT_RIGHT |
CONTROL_UP |
CONTROL_DOWN |
CONTROL_LBUTTON,
TRUE, FALSE);
vector current_pos = llGetPos();
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, current_pos.z);
pos = current_pos;
llSetStatus(STATUS_PHYSICS, TRUE);
}
}

control(key name, integer levels, integer edges)
{
if ((edges & levels & CONTROL_UP)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
linear.z += 12.0;
} else if ((edges & ~levels & CONTROL_UP)) {
linear.z -= 12.0;
}
if ((edges & levels & CONTROL_DOWN)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
linear.z -= 12.0;
} else if ((edges & ~levels & CONTROL_DOWN)) {
linear.z += 12.0;
}

if ((edges & levels & CONTROL_FWD)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
linear.x += 14.0;
} else if ((edges & ~levels & CONTROL_FWD)) {
linear.x -= 14.0;
}
if ((edges & levels & CONTROL_BACK)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
linear.x -= 14.0;
} else if ((edges & ~levels & CONTROL_BACK)) {
linear.x += 14.0;
}

if ((edges & levels & CONTROL_LEFT)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
linear.y += 8.0;
} else if ((edges & ~levels & CONTROL_LEFT)) {
linear.y -= 8.0;
}
if ((edges & levels & CONTROL_RIGHT)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
linear.y -= 8.0;
} else if ((edges & ~levels & CONTROL_RIGHT)) {
linear.y += 8.0;
}

if ((edges & levels & CONTROL_ROT_LEFT)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
angular.z += (PI / 180) * 90.0;
angular.x -= PI * 6;
} else if ((edges & ~levels & CONTROL_ROT_LEFT)) {
angular.z -= (PI / 180) * 90.0;
angular.x += PI * 6;
}
if ((edges & levels & CONTROL_ROT_RIGHT)) {
llMessageLinked(LINK_SET, 0, "key", NULL_KEY);
angular.z -= (PI / 180) * 120.0;
angular.x += PI * 6;
} else if ((edges & ~levels & CONTROL_ROT_RIGHT)) {
angular.z += (PI / 180) * 120.0;
angular.x -= PI * 6;
}
}

timer()
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, linear);

llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular);
}

}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-23-2007 08:32
The first thing that i notice is that this script is designed to be activated via linked message.
Is it getting one?

if you are trying to use the vehicle so it is activated by sitting then you will need to handle the changed event. The code will slot in almost exactly inplace of the linked message handler.

I also not that although you set up a listen on channel 0, which is not a good practise in itself, you dont actually have a listen event handler to receive any input.
Naismith Miles
Registered User
Join date: 22 Mar 2007
Posts: 4
04-23-2007 08:36
Ahh, I'll try that, thanks!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-23-2007 08:39
From: Naismith Miles
Ahh, I'll try that, thanks!



YW, once we haev it working we can start talking about optomisation!