2008年11月19日
チョッパーの作り方 - 逐次解説
ついでだな... うん ついでだ
-----
というわけで もう一つ フリーなスクリプトを流用したやつを解読してみよう...
-----
というわけで ここでの チョッパーは ヘリコプターでも なんでもなくて バイク
-----
Walking Jun:チョッパー
-----
これ
-----
というわけで いつものように 整形したのを上げときます(次回以降解説)
-----
(続く)
-----
というわけで もう一つ フリーなスクリプトを流用したやつを解読してみよう...
-----
というわけで ここでの チョッパーは ヘリコプターでも なんでもなくて バイク
-----
Walking Jun:チョッパー
-----
これ
-----
というわけで いつものように 整形したのを上げときます(次回以降解説)
-----
//-----
// File: BMW Motor.lsl
// Date Author number of nodes
// 2008/11/16 walkinglint 156
//
key agent;
vector PUSH_OFF = <0, 10, 10>;
integer gLightsOn = FALSE;
integer iChan = 0;
key owner;
vector startColor = <1, 0.5, 0.5>;
vector endColor = <1, 0, 0>;
integer onoff = TRUE;
string last_wheel_direction;
string cur_wheel_direction;
default {
state_entry() {
gLightsOn = FALSE;
llMessageLinked(LINK_SET, gLightsOn, "lights_off", "");
llSetSitText("Ride");
// llSitTarget(<0.18, 0.00, 0.4>, <0.0, -0.08, 0.0, 1>);
llSitTarget(<-0.3, 0.00, 0.3>, <0.0, -0.08, 0.0, 1>);
llSetCameraEyeOffset(<-6.0, 0.0, 3.0>);
llSetCameraAtOffset(<3.0, 0.0, 1.0>);
llSetVehicleFlags(-1);
llSetVehicleType(VEHICLE_TYPE_CAR);
llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY
| VEHICLE_FLAG_LIMIT_MOTOR_UP);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.80);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.2);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.5);
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000.0, 0.50, 1000.0>);
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <10.0, 5.0, 1000.0>);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.75);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.25);
llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 1.0);
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.01);
owner = llGetOwner();
llListen(iChan, "", owner, "");
}
//
// touch_start(integer num)
// {
//
//
// if(llDetectedKey(0) != llGetOwner())
// {
//
// llWhisper(0, "AKIRA bike");
//
// }
// else
// {
// if(llAvatarOnSitTarget() != llGetOwner()) llWhisper(0, "Right Click and choose 'Ride' from the pie menu.");
// }
//
// }
listen(integer chan, string name, key id, string msg) {
list command = llCSV2List(msg);
// Lights
if (chan == iChan & msg == "lights on") {
gLightsOn = TRUE;
llMessageLinked(LINK_SET, gLightsOn, "lights_on", "");
}
if (chan == iChan & msg == "lights off") {
gLightsOn = FALSE;
llMessageLinked(LINK_SET, gLightsOn, "lights_off", "");
}
// Colour presets
if (llList2String(command, 0) == "color" | llList2String(command, 0) == "colour") {
if (llList2String(command, 1) == "red") {
startColor = <1, 0.5, 0.5>;
endColor = <1, 0, 0>;
}
if (llList2String(command, 1) == "green") {
startColor = <0.5, 1, 0.5>;
endColor = <0, 1, 0>;
}
if (llList2String(command, 1) == "blue") {
startColor = <0, 1, 1>;
endColor = <0, 0.25, 1>;
}
if (llList2String(command, 1) == "purple") {
startColor = <1, 0.5, 1>;
endColor = <1, 0, 1>;
}
if (llList2String(command, 1) == "yellow") {
startColor = <1, 1, 0.5>;
endColor = <1, 1, 0>;
}
}
// Colour via RGB values
if (llList2String(command, 0) == "rgb") {
if (llList2String(command, 1) != "") {
startColor = <1, 0.5, 0.5>;
endColor = <1, 0, 0>;
}
}
}
changed(integer change) {
if (change & CHANGED_LINK) {
key agent = llAvatarOnSitTarget();
if (agent) {
if (agent != llGetOwner()) {
llSay(0, "You aren't the owner");
llUnSit(agent);
llPushObject(agent, <0, 0, 100>, ZERO_VECTOR, FALSE);
} else {
llTriggerSound("bike_start", 1);
llSleep(.4);
llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llSleep(.1);
llCollisionSound("", 0);
llSetTimerEvent(0.5);
llLoopSound("bike_idle", 1);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
} else {
llSetTimerEvent(0);
llStopSound();
llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llReleaseControls();
llStopAnimation("NN riding 1 4");
llPushObject(llGetOwner(), PUSH_OFF, <0, 0, 0>, TRUE);
gLightsOn = FALSE;
llMessageLinked(LINK_SET, gLightsOn, "lights_off", "");
}
}
}
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();
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, <29.1,0,0>);
}
if (level & CONTROL_BACK) {
llLoopSound("bike_drive", 1);
llMessageLinked(LINK_SET, gLightsOn, "brake_on", "");
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 1, 0> );
if (!llGetStatus(STATUS_PHYSICS)) {
llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llCollisionSound("", 0);
}
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <-10, 0, 0>);
}
if (level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) {
llLoopSound("bike_drive", 1);
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
angular_motor.x += 25;
angular_motor.z -= 10;
}
if (level & (CONTROL_LEFT|CONTROL_ROT_LEFT)) {
llLoopSound("bike_drive",1);
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
angular_motor.x -= 25;
angular_motor.z += 10;
// llWhisper(0,(string)llGround(<0, 0, 0>) + " -- " + (string)llGetPos());
}
if (level & (CONTROL_UP)) {
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
angular_motor.y -= 75;
}
if (level & (CONTROL_DOWN)) {
// llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
angular_motor.y += 75;
}
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);
}
}
(続く)
Posted by walkinglint at 12:36│Comments(0)
│walking のスクリプティング講座