02-13-2007 03:57
Hi, I'm trying to link 2 poseballs scripted as a vehicle to make a couple's walk. My first attempt to write the script for the "male" poseball failed dismally - my avatar just sits on the ball instead of playing the required animation, and the forward key controls the camera instead of the vehicle's movement. As far as I can determine, nothing at all works, except for the Sit text being displayed in the pie menu. I must be making some very elementary mistake. Could someone please take a look and point me in the right direction? Thanks!

======

float forward_power = 1; //Power used to go forward (1 to 30)
float reverse_power = -1; //Power ued to go reverse (-1 to -30)
float turning_ratio = 1.0; //How sharply the vehicle turns. Less is more sharply. (.1 to 10)
string sit_message = "Link arms"; //Sit message

string last_wheel_direction;
string cur_direction;

hide()
{
llSetAlpha(0.0, ALL_SIDES);
}

unhide()
{
llSetAlpha(1.0, ALL_SIDES);
}

default
{
state_entry()
{
llSetSitText(sit_message);
llSetVehicleType(VEHICLE_TYPE_CAR);
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent != NULL_KEY)
{
llSetStatus(STATUS_PHYSICS, TRUE);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
else
{
llSetStatus(STATUS_PHYSICS, FALSE);
llReleaseControls();
unhide();
llResetScript();
}
}

}

run_time_permissions(integer perm)
{
if (perm)
{
llStopAnimation("sit";);
llStartAnimation("LinkedArmsMaleStand";);
hide();
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT |
CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
}
}

control(key id, integer level, integer edge)
{
integer reverse=1;
vector angular_motor;

vector vel = llGetVel();
float speed = llVecMag(vel);

if(level & CONTROL_FWD)
{
cur_direction = "FORWARD";
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power,0,0> );
reverse=1;
}
if(level & CONTROL_BACK)
{
cur_direction = "BACK";
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <reverse_power,0,0> );
reverse = -1;
}

if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
{
cur_direction = "RIGHT";
angular_motor.z -= speed / turning_ratio * reverse;
}

if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
{
cur_direction = "LEFT";
angular_motor.z += speed / turning_ratio * reverse;
}

llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
llStopAnimation("LinkedArmsMaleStand";);
llStartAnimation("LinkedArmsMaleWalk";);
} //end control

} //end default