チョッパーの作り方 - 逐次解説(その3)

walkinglint

2008年11月19日 16:04


    run_time_permissions(integer perm) {
if (perm) {
llStartAnimation("NN riding 1 4");
-----
アクションを起動
-----
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT
| CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
-----
矢印キー等からの入力を取得
-----
}
}
control(key id, integer level, integer edge) {
vector angular_motor;
vector vel = llGetVel();
-----
速度を vel に設定
-----
if (level & CONTROL_FWD) {
llLoopSound("bike_drive", 1);
llMessageLinked(LINK_SET, gLightsOn, "brake_off", "");
if (!llGetStatus(STATUS_PHYSICS)) {
llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llCollisionSound("", 0);
}
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, );
-----
前進
-----
}
if (level & CONTROL_BACK) {
llLoopSound("bike_drive", 1);
llMessageLinked(LINK_SET, gLightsOn, "brake_on", "");
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, );
if (!llGetStatus(STATUS_PHYSICS)) {
llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llCollisionSound("", 0);
}
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, );
-----
ブレーキ?
-----
}
if (level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) {
llLoopSound("bike_drive", 1);
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, );
angular_motor.x += 25;
angular_motor.z -= 10;
}
-----
右に
-----
if (level & (CONTROL_LEFT|CONTROL_ROT_LEFT)) {
llLoopSound("bike_drive",1);
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, );
angular_motor.x -= 25;
angular_motor.z += 10;
// llWhisper(0,(string)llGround() + " -- " + (string)llGetPos());
}
-----
左に
-----
if (level & (CONTROL_UP)) {
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, );
angular_motor.y -= 75;
}
if (level & (CONTROL_DOWN)) {
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, );
angular_motor.y += 75;
}
-----
この辺はいまいちわからない w
-----
if ((edge & CONTROL_FWD) && (level & CONTROL_FWD)) {
//
// We have a few message links to communicate to the other
// scritps when we start to accelerate and let off the gas.
//
llMessageLinked(LINK_SET, 0, "burst", "");
}
if ((edge & CONTROL_BACK) && !(level & CONTROL_BACK)) {
llMessageLinked(LINK_SET, gLightsOn, "brake_off", "");
}
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
-----
ここで 指示
-----
}
timer() {
llLoopSound("bike_idle", 1);
-----
0.5 秒毎に再生
-----
}
}
walking のスクリプティング講座