Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Steering wheel

Stylez Gomez
Union Micro
Join date: 4 Jun 2004
Posts: 146
07-07-2004 15:46
This could have been posted in the vehicle forum but despite the fact it's in a vehicle it's more of a general scripting problem.

Anyway.. I'm trying to get my steering wheel in a boat to turn depending on which key you press. Here is an excerpt from the main script which is called when the forward key is pressed.. there are similar actions taken for the other keys:

CODE

if(level & CONTROL_FWD)
{
// Set cruising speed faster
if(speed < 120)
{
speed +=2;
llMessageLinked(LINK_ALL_CHILDREN, (integer)speed, "", NULL_KEY);
}
if(wheel_state != "WHEEL_STRAIGHT")
{
wheel_state = "WHEEL_STRAIGHT";
llMessageLinked(7,0,wheel_state,NULL_KEY);
}
}


Now here is the code in the steering wheel to handle the link message:

CODE

link_message(integer sender_num, integer num, string str, key id)
{

if(str == "WHEEL_DEFAULT")
{
state default;
}

if(str == "WHEEL_STRAIGHT") //center wheel
{
SetLocalRot(llEuler2Rot(<0,-1 * PI_BY_TWO,0> ));

}

if(str == "WHEEL_LEFT") //turn left
{
SetLocalRot(llEuler2Rot(<-1 * PI_BY_TWO / 2, -1 * PI_BY_TWO, 0> ));

}

if(str == "WHEEL_RIGHT") //turn right
{


SetLocalRot(llEuler2Rot(<PI_BY_TWO / 2, -1 * PI_BY_TWO, 0> ));

}



Now I will explain what the problem is. When I press the left key for instance, it will message the wheel and tell it to turn left. Then the wheel will stay turned left until it is told otherwise. Since this is a modified wheel turning script from a car script (Andrew Perkins).. it assume you will press forward anytime you want to move forward, thus resending the command to center the wheel.. BUT.. mine is in a boat, so you press forward to get moving, then you essentially never touch it again, hense it never tells the wheel to center.

I've thought about using
CODE

if(edge & CONTROL_FWD)

but I'm not quite sure how it works. I've also tried putting a time in the steering wheel to center it every 1 second but it gives some unpredictable and unrealistic effects.

Well that is the just of the problem I probably didn't explain it too good but maybe someone has went through this before and can give me a hint. :D
Aaron Perkins
Registered User
Join date: 14 Nov 2003
Posts: 50
07-07-2004 17:29
My name is Aaron Perkins BTW....


What you might want to do its recenter the steering wheel when the user releases the left or right key...

if ( edges & ~levels & CONTROL_RIGHT )
{
llMessageLinked(7,0,"WHEEL_STRAIGHT",NULL_KEY);
}

Or something like that ....
Stylez Gomez
Union Micro
Join date: 4 Jun 2004
Posts: 146
07-07-2004 18:24
From: someone

My name is Aaron Perkins BTW....

Yikes, sorry Aaron, I got a bad memory. I'll give that a try, thank you.