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.
