2008年07月10日
ラジコンヘリのスクリプト
RL では 小型のラジコンヘリが流行っているそうですが
-----
SL では 前に一度(Walking Jun:ラジコンヘリ)見たことがありますが
-----
SL Forums - Library: Simple RC Chopper Script
-----
に そういうスクリプト があったので試してみました
-----
-----
-----
-----
-----
クリックした後は 矢印キー と Page Up/Down で制御できます
-----
前に見たもののように 地面にぶつかると壊れてしまうようなこともなく 結構楽しいかも w
-----
少し整形だけしたリストを上げておきます
-----
SL では 前に一度(Walking Jun:ラジコンヘリ)見たことがありますが
-----
SL Forums - Library: Simple RC Chopper Script
-----
に そういうスクリプト があったので試してみました
-----
-----
-----
-----
-----
クリックした後は 矢印キー と Page Up/Down で制御できます
-----
前に見たもののように 地面にぶつかると壊れてしまうようなこともなく 結構楽しいかも w
-----
少し整形だけしたリストを上げておきます
//
// File: RCChopper.lsl
// Date Author number of nodes
// 2008/7/10 walkinglint 97
// 2008/7/9 walkinglint 97
//
//
// /////////////////////////////////
// Simple RC Chopper Script//
// By Mrc Homewood///////
// if used include credit/////
// ////////////////////////////////
//
// http://forums.secondlife.com/showthread.php?t=236698
float speed = 0;
float turn = 0;
float lift = 0;
integer move = FALSE;
integer turning = FALSE;
key avatar;
integer on;
default {
state_entry() {
llSay(0, "Preparing Helicopter");
llSetVehicleType(VEHICLE_TYPE_AIRPLANE);
llRemoveVehicleFlags(-1);
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1, 2, 1>);
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <0.5, 0.5, 0.5>);
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0>);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.2);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.75);
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0>);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.2);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.3);
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0);
llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0);
llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 1000);
llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0.99);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 2);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 2);
llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.7);
llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 0.5);
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.2);
llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1>);
llRemoveVehicleFlags(VEHICLE_FLAG_HOVER_WATER_ONLY
| VEHICLE_FLAG_HOVER_TERRAIN_ONLY
| VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT
| VEHICLE_FLAG_LIMIT_ROLL_ONLY
| VEHICLE_FLAG_HOVER_UP_ONLY
| VEHICLE_FLAG_LIMIT_MOTOR_UP);
llStopSound();
llCollisionSound("", 0.0);
llSetStatus(STATUS_PHYSICS, FALSE);
llSay(0,"Helicopter is ready to fly");
}
on_rez(integer param) {
llResetScript();
}
run_time_permissions(integer perm) {
if (perm & PERMISSION_TAKE_CONTROLS) {
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT
| CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN,
TRUE, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
} else {
llReleaseControls();
llSetStatus(STATUS_PHYSICS, FALSE);
}
}
touch_start(integer total_number) {
avatar = llDetectedKey(0);
string name = llKey2Name(avatar);
if ((avatar == llGetOwner()) && (on == TRUE)) {
llSetStatus(STATUS_PHYSICS, FALSE);
llStopSound();
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llReleaseControls();
on = FALSE;
} else if ((avatar == llGetOwner()) && (on == FALSE)) {
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llRequestPermissions(avatar, PERMISSION_TAKE_CONTROLS);
on = TRUE;
}
}
control(key name, integer held, integer change) {
if (held & CONTROL_FWD) {
speed = 5; // fwd power
move = TRUE;
}
if (held & CONTROL_BACK) {
speed = -3; // reverse power
move = TRUE;
}
if (held & CONTROL_UP) {
lift = 2; // up speed
move = TRUE;
}
if (held & CONTROL_DOWN) {
lift = -2; // down speed
move = TRUE;
}
if ((held & CONTROL_ROT_RIGHT) || (held & CONTROL_RIGHT)) {
turn = 5; // right turn/bank speed
turning = TRUE;
}
if ((held & CONTROL_ROT_LEFT) || (held & CONTROL_LEFT)) {
turn = -5; // left turn/bank speed
turning = TRUE;
}
if (move) {
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION,);
lift = 0;
speed = 0;
move = FALSE;
}
if (turning) {
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,);
turn = 0;
turning = FALSE;
}
}
}
Posted by walkinglint at 10:03│Comments(0)
│ラジコン