Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

jetski control problem

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
01-13-2008 09:31
ive been building/scripting a jet ski all day and i seam to have finaly ran into a script problem xD

im making 2 speeds, regular and turbo. when i press up it will activate the turbo if not already actiatd and when i press control down ot will deactivate the turbo, i cant seam to get it fixed, i belive it might be a issues in the else if statements i have no idea, ere is all the control related systems

CODE

=====
integers
=====
integer fast;
integer fwd;
integer camon;
float fastspeed = 25;
float slowspeed = 15;
float backspeed = 10.0;
float floatheight = .1;
float turnspeed = 1.5;
vector angular_motor;
=====
controls
=====
control(key name, integer levels, integer edges)
{
float side = 0.0;
float forw = 0.0;
float move = 0.0;
float turn;

if ((edges & CONTROL_UP & fast == FALSE))
{
fast = TRUE;
llOwnerSay("Turbo Speed Activated");
}
else if ((edges & CONTROL_UP & fast == TRUE))
{
fast = FALSE;
llOwnerSay("Turbo Speed Deactivated");
}
else if (levels & CONTROL_FWD)
{
move = slowspeed;
turn = 1.0 * turnspeed;
forw = PI / 2;
angular_motor.y = -2.1;
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, .25);
fwd = TRUE;
}
else if ((levels & CONTROL_FWD & fast == TRUE));
{
move = fastspeed;
turn = 1.5 * turnspeed;
forw = 2 * PI / 3;
angular_motor.y = -1.3;
}
if (levels & CONTROL_BACK)
{
move = -backspeed;
forw = -PI / 3;
turn = -1.0 * turnspeed;
}

else if (levels & (CONTROL_LEFT | CONTROL_ROT_LEFT))
{
if(fwd == TRUE)
{
angular_motor.x -= 1.1;
angular_motor.z += 1;
}
else if(fwd == FALSE)
{
angular_motor.x -= .7;
angular_motor.z += 1;
}
}
else if (levels & (CONTROL_RIGHT | CONTROL_ROT_RIGHT))
{
if(fwd == TRUE)
{
angular_motor.x += 1.1;
angular_motor.z -= 1;
}
else if(fwd == FALSE)
{
angular_motor.x += .7;
angular_motor.z -= 1;
}
}

if (move == 0)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0>);
}
else
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION,
<move, 0, 0>);
}
}
====
timer
====
timer()
{
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
angular_motor=<0,0,0>;
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, floatheight);
fwd = FALSE;
}
}
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
01-14-2008 10:01
i dunno, but isn't this section.... applicable to two instances?

else if (levels & CONTROL_FWD)
{
move = slowspeed;
turn = 1.0 * turnspeed;
forw = PI / 2;
angular_motor.y = -2.1;
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, .25);
fwd = TRUE;
}
else if ((levels & CONTROL_FWD & fast == TRUE));
{
move = fastspeed;
turn = 1.5 * turnspeed;
forw = 2 * PI / 3;
angular_motor.y = -1.3;
}


oh, yeah. because if levels & CTRL_FWD & fast == TRUE is reading true for if levels & CTRL_FWD. because you didnt also say & fast == FALSE.

so i think its reading the first one on all instances of ctrl_fwd being held down.

um, and shouldnt it be if ((levles & CTRL_FWD) && fast == TRUE))?

not sure, im not really a scripting guru geek. i fake it :X
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705