Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Vehicle Opensim BulletSim Helicopter  

Opensim BulletSim Helicopter

The helicopter is alaso availabe in an IAR

Category: Vehicle
By : Shin Ingen @ http://ingen-lab.com:8002
Created: 2015-03-17 Edited: 2015-03-17
Worlds: Second Life

the Zip file

Download all files for Opensim BulletSim Helicopter
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1
2 //Physics Engine:
3 //
4 //You’ll notice that the script itself is configured to take on an ODE settings or BulletSim settings by changing the variable gPhysEng (line 105) to “0” for ODE or “1” for BulletSim. This option was really meant for vehicle type CAR since BulletSim flying objects have functions that do not exist in ODE. It may or may not work in ODE.
5 //
6 //Camera Settings:
7 //
8 //You also have the option to use Fixed Cam or Dynamic Cam by changing the variable gCamFixed to “0” for Dynamic Cam or “1” for Fixed Cam.
9 //
10 //Controls:
11 //
12 //Hover Mode: Page UP and Page Down Keys controls elevation, Up and Down Arrow Keys to move forward or backward and finally Left and Right Arrow Keys to spin left or right.
13 //
14 //Fly Mode: UP and Page Down Keys controls elevation, Up and Down Arrow Keys to move forward or backward and finally Left and Right Arrow Keys to roll left or right.
15 //
16 //Speed: Shift + Right Arrow Key to gear up and Shift + Left Arrow Key to gear down.
17 //
18 //Rotor Blade Rotation: This is a scriptless rotation and works by renaming your rotors spin_x, spin_y or spin_z. It all depends on your rotor blade’s true center when you upload it. Your rotor blade should be one piece for this to work, for example, the Apache Helicopter’s rotor blade and shaft are one piece so it appears that both are rotating.
19 //
20 //That’s about it, the rest should be self explanatory within the script itself. I hope that you can find it useful and sharing back your improvements will be greatly appreciated.
21 //
22 //Happy Scripting Everyone!
23
24 //*******************************************************
25 // Shin Ingen @ http://ingen-lab.com:8002
26 // LSL | OPENSIM | BulletSim | Varregion
27 // iTEC + e3s + DC (ENGINE SPEED SENSITIVE STEERING WITH DYNAMIC CAMERA)
28 // JANUARY 28, 2013
29 // TODO: KEYWORD PROCESSOR FOR ** PRIM ANIMATION | AVATAR ANIMATION | SOUNDS | MENU | HUD | DYNAMIC CAMERA
30 //*******************************************************
31
32 //---PERMISSION VARIABLES---------------------------------------------
33 integer gDrivePermit = 1; // 0=EVERYONE 1=OWNERONLY
34 string gSitMessage = "Ride";
35 string gUrNotAllowedMessage = "Vehicle is Locked";
36 vector gSitTarget_Pos = <2.5,1.6,1.9>;
37 vector gSitTarget_Rot;
38 key gOldAgent;
39 key gAgent;
40 integer gRun; //ENGINE RUNNING
41 integer gMoving; //VEHICLE MOVING
42 //integer gIdle;
43 //---END PREMISSION----------------------------------------------------
44
45 //---ANIMATION VARIABLES-----------------------------------------------
46 string gDrivingAnim = "driverLH-64-64";
47 //---------------------------------------------------------------------
48
49 //---CAMERA VARIABLES--------------------------------------------------
50 //***CONSTANT**********************************************************
51 integer gCamFixed=0; // INITVAL=0 0=FOLLOW CAM 1=FIXED CAM
52 //integer gCamAct; // INITVAL=1 0=INACTIVE 1=ACTIVE
53 //integer gCamFocLocked; // INITVAL=FALSE (TRUE or FALSE)
54 //integer gCamPoslocked; // INITVAL=FALSE (TRUE or FALSE)
55 //***SLIDERS***********************************************************
56 //float gCamBAng; // INITVAL=2.0 (0 to 180) DEGREES
57 //float gCamBLag; // INITVAL=0.1 (0 to 3) SECONDS
58 //float gCamDist; // INITVAL=8.0 (0.5 to 10) METERS
59 //float gCamFocLag; // INITVAL=0.1 (0 to 3) SECONDS
60 //float gCamFocThresh; // INITVAL=0.5 (0 to 4) METERS
61 //float gCamPitch; // INITVAL=20.0 (-45 to 80) DEGREES
62 //float gCamPoslag; // INITVAL=0.1 (0 to 3) SECONDS
63 //float gCamPosthresh; // INITVAL=0.5 (0 to 4) METERS
64 //vector gCamFocOff; // INITVAL=<0.10,0,0> <-10,-10,-10> to <10,10,10> METERS
65 //----END CAMERA-------------------------------------------------------
66
67 //---SOUND VARIABLES---------------------------------------------------
68 string gSoundFlight = "s_flight";
69 string gSoundHorn = "s_horn";
70 string gSoundStartup = "BLACKHAWK-HELI-START";
71 string gSoundIdle = "BLACKHAWK-HELI-IDLE";
72 string gSoundSlow = "BLACKHAWK-HELI-RUN";
73 string gSoundAggressive = "BLACKHAWK-HELI-RUNFAST";
74 string gSoundGearUp = "s_gearup";
75 string gSoundGearDown = "s_geardown";
76 string gSoundRev = "s_rev";
77 string gSoundAlarm = "s_alarm";
78 string gSoundStop = "s_rev";
79 //NEED KEYWORD SOUND PROCESSOR
80 integer gOldSound=3; //variable for sound function
81 integer gNewSound=3;
82 //---------------------------------------------------------------------
83
84 //---iTEC - STOCK ENGINE GLOBAL VARIABLES------------------------------
85 list gTSvarList;
86 float gVLMT=0.90; //INITVAL=0.90
87 float gVLMDT=0.10; //INITVAL=0.10
88 vector gVLFT=<8.0, 3000.0, 8.0>; //INITVAL=<8.0, 3000.0, 8.0>
89 vector gVAFT=<0.10, 0.10, 0.10>; //INITVAL=<0.10, 0.10, 0.10>
90 float gVADE=0.20; //INITVAL=0.20
91 float gVADT=0.50; //INITVAL=0.10
92 float gVAMT=1.0; //INITVAL=0.10
93 float gVAMDT=0.10; //INITVAL=0.10
94 float gVLDE=1.0; //INITVAL=1.0
95 float gVLDT=0.10; //INITVAL=0.10
96 float gVVAE=0.50; //INITVAL=0.50
97 float gVVAT=5.0; //INITVAL=5.0
98 float gVHE=0.0; //INITVAL=0.0
99 float gVHT=0.0; //INITVAL=0.0
100 float gVHH=0.0; //INITVAL=0.0
101 float gVB=0.9; //INITVAL=0.0
102 float gVBE=1.0; //INITVAL=1.0
103 float gVBM=0.5; //INITVAL=0.5
104 float gVBT=0.5; //INITVAL=0.5
105 float gVerticalThrust=7.0;
106 //---------------------------------------------------------------------
107
108 //---iTEC POWERTRAIN + (e3s) GLOBAL VARIABLES -------------------------
109 integer gGear;
110 integer gNewGear;
111 float gGearPower;
112 float gReversePower = -5;
113 list gGearPowerList = [ 5, // HOVER
114 15, // 15-KNOTS
115 30, // 30-KNOTS
116 40, // 40-KNOTS
117 50, // 50-KNOTS
118 60, // 60-KNOTS
119 70, // 70-KNOTS
120 100, // 100-KNOTS
121 150, // 150-KNOTS
122 200, // 200-KNOTS
123 225, // 225-KNOTS
124 250 // 250-KNOTS
125 ];
126 //integer gGearCount;
127 string gPhysEngDesc;
128 integer gPhysEng=1; // 0=ODE| 1=Bullet
129 float gTurnMulti=1.012345;
130 float gTurnRatio;
131 list gTurnRatioList;
132 string gGearName;
133 list gGearNameList =[ "HOVER",
134 "15-KNOTS",
135 "20-KNOTS",
136 "40-KNOTS",
137 "50-KNOTS",
138 "60-KNOTS",
139 "70-KNOTS",
140 "100-KNOTS",
141 "150-KNOTS",
142 "200-KNOTS",
143 "225-KNOTS",
144 "250-KNOTS"
145 ];
146 float gSpeed=0;
147 //---------------------------------------------------------------------
148
149 //---------------------------------------------------------------------
150 //NEED A KEYWORD PRIM ANIMATION PROCESSOR
151 integer gTurnCount;
152 string gTurnAngle = "NoTurn"; // LeftTurn or RightTurn or NoTurn
153 string gNewTurnAngle = "NoTurn";
154 string gTireSpin = "ForwardSpin"; // ForwardSpin or BackwardSpin or NoSpin
155 string gNewTireSpin = "ForwardSpin";
156 string gRotorSpin = "NoRotate"; // NoRotate or SlowRotate or FastRotate
157
158 integer gTcountL; //for cornerF
159 Xinteger gTcountR;
160
161 //---------------------------------------------------------------------
162
163 //---MENU HANDLER------------------------------------------------------
164 list MENU_MAIN = ["Align", "Hello"]; // up to 12 items in list
165 integer menu_handler;
166 integer menu_channel;
167 //---------------------------------------------------------------------
168
169 //=======================================================================
170 //==== E N D G L O B A L V A R I A B L E D E C L A R A T I O N ====
171 //=======================================================================
172 init_TSvar(integer i){
173 if(i==0){
174 gTSvarList = [ 3.0, // how fast to reach max speed
175 0.10, // how fast to reach min speed or zero
176 <7.0,3000.0,100.0>, // XYZ linear friction
177 <0.10,0.10,0.20>, // XYZ angular friction
178 0.90, // how fast turning force is applied
179 0.50, // how fast turning force is released
180 1.0, // adjusted on 0.7.6
181 0.10,
182 0.20,
183 0.10,
184 0.50,
185 5.0,
186 0.0,
187 0.0,
188 0.0,
189 0.9,
190 1.0,
191 0.5,
192 0.5
193 ];
194 }else{
195 gTSvarList = [ 0.50, // how fast to reach max speed
196 10, // how fast to reach min speed or zero
197 <1.0,1.0,1.0>, // XYZ linear friction
198 <1.0,1000.0,1000.0>, // XYZ angular friction
199 0.20, // how fast turning force is applied
200 0.1, // how fast turning force is released
201 0.1, // adjusted on 0.7.6
202 10.0,
203 0.10,
204 10.0,
205 1.0,
206 2.0,
207 0.0,
208 0.0,
209 0.0,
210 0.99,
211 1.0,
212 0.5,
213 0.5
214 ];
215 }
216 gVLMT=llList2Float(gTSvarList,0);
217 gVLMDT=llList2Float(gTSvarList,1);
218 gVLFT=llList2Vector(gTSvarList,2);
219 gVAFT=llList2Vector(gTSvarList,3);
220 gVAMT=llList2Float(gTSvarList,4);
221 gVAMDT=llList2Float(gTSvarList,5);
222 gVLDE=llList2Float(gTSvarList,6);
223 gVLDT=llList2Float(gTSvarList,7);
224 gVADE=llList2Float(gTSvarList,8);
225 gVADT=llList2Float(gTSvarList,9);
226 gVVAE=llList2Float(gTSvarList,10);
227 gVVAT=llList2Float(gTSvarList,11);
228 gVHE=llList2Float(gTSvarList,12);
229 gVHT=llList2Float(gTSvarList,13);
230 gVHH=llList2Float(gTSvarList,14);
231 gVB=llList2Float(gTSvarList,15);
232 gVBE=llList2Float(gTSvarList,16);
233 gVBM=llList2Float(gTSvarList,17);
234 gVBT=llList2Float(gTSvarList,18);
235 }
236
237 init_PhysEng(){
238 string msg;
239 if(gPhysEng==0){
240 msg =":: is tuned for OpenDynamicsEngine";
241 }else if(gPhysEng==1){
242 msg =":: is tuned for BulletSim";
243 }
244
245 if(gPhysEng==0){
246 gTurnMulti=gTurnMulti;
247 init_TSvar(0);
248 gTurnRatioList = [ 2.4, // HOVER
249 2.4, // 15-KNOTS
250 2.4, // 30-KNOTS
251 2.5, // 40-KNOTS
252 4.5, // 50-KNOTS
253 5.0, // 60-KNOTS
254 5.5, // 70-KNOTS
255 6.5, // 100-KNOTS
256 7.5, // 150-KNOTS
257 10.0, // 200-KNOTS
258 10.0, // 225-KNOTS
259 10.0 // 250-KNOTS
260 ];
261 gGearPowerList = [ 5, // HOVER
262 15, // 15-KNOTS
263 30, // 30-KNOTS
264 40, // 40-KNOTS
265 50, // 50-KNOTS
266 60, // 60-KNOTS
267 70, // 70-KNOTS
268 100, // 100-KNOTS
269 150, // 150-KNOTS
270 200, // 200-KNOTS
271 225, // 225-KNOTS
272 250 // 250-KNOTS
273 ];
274
275
276 }else{
277 gTurnMulti=1.12345;
278 init_TSvar(1);
279 gTurnRatioList = [ 1.3, // HOVER
280 1.5, // 15-KNOTS
281 2.0, // 30-KNOTS
282 2.5, // 40-KNOTS
283 2.9, // 50-KNOTS
284 3.3, // 60-KNOTS
285 5.0, // 70-KNOTS
286 6.0, // 100-KNOTS
287 7.0, // 150-KNOTS
288 8.0, // 200-KNOTS
289 9.0, // 225-KNOTS
290 10.0 // 250-KNOTS
291 ];
292
293 gGearPowerList = [ 5, // HOVER
294 15, // 15-KNOTS
295 30, // 30-KNOTS
296 40, // 40-KNOTS
297 50, // 50-KNOTS
298 60, // 60-KNOTS
299 70, // 70-KNOTS
300 100, // 100-KNOTS
301 150, // 150-KNOTS
302 200, // 200-KNOTS
303 225, // 225-KNOTS
304 250 // 250-KNOTS
305 ];
306
307 }
308 llSay(0,msg);
309 }
310
311 preload_sounds(){
312 llPreloadSound(gSoundFlight);
313 llPreloadSound(gSoundHorn);
314 llPreloadSound(gSoundStartup);
315 llPreloadSound(gSoundIdle);
316 llPreloadSound(gSoundSlow);
317 llPreloadSound(gSoundAggressive);
318 llPreloadSound(gSoundGearUp);
319 llPreloadSound(gSoundGearDown);
320 llPreloadSound(gSoundRev);
321 llPreloadSound(gSoundAlarm);
322 }
323
324 init_engine(){
325 gRun = 0;
326 llSetSitText(gSitMessage);
327 llCollisionSound("", 0.0);
328 gSitTarget_Rot = llRot2Euler( llGetRootRotation() ); // SIT TARGET IS BASED ON VEHICLE'S ROTATION.
329 llSitTarget(gSitTarget_Pos, llEuler2Rot(DEG_TO_RAD * gSitTarget_Rot));
330 gOldSound=3;
331 gNewSound=3;
332 gTireSpin = "NoSpin";
333 gTurnAngle = "NoTurn";
334 gRotorSpin = "NoRotate";
335 llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
336 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY); // NO SPIN
337 llMessageLinked(LINK_SET, 0, gTurnAngle, NULL_KEY); // NO TURN
338 llMessageLinked(LINK_SET, 0, gRotorSpin, NULL_KEY); // SLOW SPIN
339 }
340
341 init_followCam(){
342
343 powershift(0);
345 CAMERA_ACTIVE, 1, // 0=INACTIVE 1=ACTIVE
346 CAMERA_BEHINDNESS_ANGLE, 15.0, // (0 to 180) DEGREES
347 CAMERA_BEHINDNESS_LAG, 1.0, // (0 to 3) SECONDS
348 CAMERA_DISTANCE, 30.0, // ( 0.5 to 10) METERS
349 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 6.0, // (-45 to 80) DEGREES
350 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
351 CAMERA_POSITION_LAG, 0.01, // (0 to 3) SECONDS
352 CAMERA_POSITION_THRESHOLD, 30.0, // (0 to 4) METERS
353 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
354 CAMERA_FOCUS_LAG, 0.01 , // (0 to 3) SECONDS
355 CAMERA_FOCUS_THRESHOLD, 0.01, // (0 to 4) METERS
356 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> METERS
357 ]);
358 }
359
360 init_fixedCam(float degrees) {
361 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
362 llSetCameraEyeOffset(<-20.0, 0, 8> * sitRot);
363 llSetCameraAtOffset(<4, 0, 0> * sitRot);
365 }
366
367 set_engine(){
372 llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0.00000, 0.00000, 0.00000, 0.00000>);
373 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, gVLMT);
378 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, gVAMDT);
392
393 // llRemoveVehicleFlags(vfW); // NOT FOR OPENSIM
394 // llRemoveVehicleFlags(vfA); // NOT FOR OPENSIM
395 // llSetVehicleFlags(vfG); // NOT FOR OPENSIM
396 gRotorSpin = "SlowRotate";
397 llMessageLinked(LINK_SET, 0, gRotorSpin, NULL_KEY); // SLOW SPIN
398 }
399
400 powershift(integer g){
401 if(gRun & ~gMoving){
402 if(gCamFixed==0){
404 }
405 }
406 else {
407 vector vel = llGetVel();
408 float speed = llVecMag(vel);
409 if(speed <=20){
410 if(gCamFixed==0){
412 }
413 }
414 else if((speed >=21) || (speed <=50)){
415 if(gCamFixed==0){
417 }
418 }
419 else if(speed >=51) {
420 if(gCamFixed==0){
422 }
423
424 }
425 }
426 gGearPower = llList2Integer(gGearPowerList, g);
427 }
428
429 gearshift(integer g){
430 gGearName = llList2String(gGearNameList, g);
431 enginesound();
432 llSay(0,gGearName);
433 }
434
435 nearestpi(){
436 // ALIGNS THE VEHICLE EAST WEST SOUTH NORTH BASED ON CURRENT ROTATION (PRESTAGE AND STAGE DURING DRAG MODE)
438 llSetRot( llEuler2Rot( <Rad.x, Rad.y, llRound( Rad.z / PI_BY_TWO ) * PI_BY_TWO > ) );
439 }
440
441 menu(key user,string title,list buttons)
442 {
443 llListenRemove(menu_handler);
444 menu_channel = (integer)(llFrand(99999.0) * -1);
445 menu_handler = llListen(menu_channel,"","","");
446 llDialog(user,title,buttons,menu_channel);
447 llSetTimerEvent(30.0);
448 }
449
450 showdata(string s){
451 llSetText(s+"\n.\n.\n.\n.",<1,1,.6>,1.0);
452 //llSetText("",<0,0,0>,1.0);
453 }
454
455 enginesound(){
456 vector vel = llGetVel();
457 float speed = llVecMag(vel);
458 if(speed <=15){
459 gNewSound = 0;
460 }
461 else if(speed >=50){
462 gNewSound = 2;
463 }
464 else {
465 gNewSound = 1;
466 }
467
468 if(gOldSound != gNewSound){
469 if(speed <=15){
470 llLoopSound(gSoundIdle,1.0);
471 }
472 else if(speed >=50){
473 llLoopSound(gSoundAggressive,1.0);
474 }
475 else {
476 llLoopSound(gSoundSlow,1.0);
477 }
478 gOldSound = gNewSound;
479 }
480 }
481
482 cornerFXR(){
483 vector vel = llGetVel();
484 float speed = llVecMag(vel);
485 if(speed >50){
486 llMessageLinked(LINK_SET, 0, "letsburnR", NULL_KEY);
487 }
488 }
489
490 cornerFXL(){
491 vector vel = llGetVel();
492 float speed = llVecMag(vel);
493 if(speed >50){
494 llMessageLinked(LINK_SET, 0, "letsburnL", NULL_KEY);
495 }
496 }
497
498 default {
500 {
501 init_engine();
502 state Air;
503 }
504 }
505
506 state Air{
507
509 }
510 on_rez(integer param) {
512 preload_sounds();
513 init_PhysEng();
514 }
515
516 changed(integer change){
517 if((change & CHANGED_LINK) == CHANGED_LINK){
518 gAgent = llAvatarOnSitTarget();
519 if(gAgent != NULL_KEY){
520 if( (gAgent != llGetOwner()) && (gDrivePermit == 1)){
521 llSay(0, gUrNotAllowedMessage);
522 llUnSit(gAgent);
523 llPlaySound(gSoundAlarm,1.0);
524 llPushObject(gAgent, <0,3,20>, ZERO_VECTOR, FALSE);
525 }
526 else {
528 llSetStatus(STATUS_ROTATE_Y,TRUE);
529 gOldAgent = gAgent;
530 init_PhysEng();
531 set_engine();
533 gRun = 1;
534 }
535 }
536 else {
538 gRun = 0;
539 init_engine();
540 llTriggerSound(gSoundStop,1);
541 llStopAnimation(gDrivingAnim);
542 llPushObject(gAgent, <0,3,20>, ZERO_VECTOR, FALSE);
543 llSetTimerEvent(0.0);
547 llSetCameraParams([CAMERA_ACTIVE, 0]);
548 llSetText("",<0,0,0>,1.0);
549 }
550 }
551 }
553 if(perm) {
554 gGear = 0; // LIST INDEX STARTS @ 0
555 //gNewGear = 2;
557 if(gCamFixed == 1) {
558 init_fixedCam(0);
559 }else{
560 init_followCam();
561 }
562 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
563 llMessageLinked(LINK_SET, 0, "headlight", "0");
564 llStartAnimation(gDrivingAnim);
565 llTriggerSound(gSoundStartup,1.0);
566 llSleep(1.5);
567 enginesound();
568 }
569 }
570
571 control(key id, integer held, integer change){
572 if(gRun == 0){
573 return;
574 }
575 integer reverse=1;
576 vector vel = llGetVel();
577 vector speedvec = llGetVel() / llGetRot();
578 gSpeed = llVecMag(vel);
579 gTurnRatio = llList2Float(gTurnRatioList,gGear);
580
581 if((held & change & CONTROL_RIGHT) || ((gGear >= 11) && (held & CONTROL_RIGHT))){
582 gGear=gGear+1;
583 if(gGear < 0) gGear = 0;
584 if(gGear > 11) gGear = 11;
585 gearshift(gGear);
586 }
587
588 if((held & change & CONTROL_LEFT) || ((gGear >= 11) && (held & CONTROL_LEFT))){
589 gGear=gGear-1;
590 if(gGear < 0) gGear = 0;
591 if(gGear > 11) gGear = 11;
592 gearshift(gGear);
593
594 }
595 if(held & CONTROL_FWD){
596 if(gGear == 0) {
598 }else{
600 }
601 if(gGear == 1) {
602 //llMessageLinked(LINK_SET, 0, "letsburn", NULL_KEY);
603 //llMessageLinked(LINK_SET, 0, "letsscreech", NULL_KEY);
604 //llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
605 }
606 if(gGear == 2) {
607 }
608 if(gGear == 3) {
609 }
610 if(gGear == 4) {
611 }
612 if(gGear == 5) {
613 }
614 if(gGear == 6) {
615 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
616 }
617 if(gGear == 7) {
618 }
619 if(gGear == 8) {
620 }
621 if(gGear == 9) {
622 }
623 if(gGear == 10) {
624 }
625 if(gGear == 11) {
626 }
627 powershift(gGear);
629 gMoving=1;
630 reverse=1;
631 gNewTireSpin = "ForwardSpin";
632
633 }
634
635 if(held & CONTROL_BACK){
639 gTurnRatio = -2.0;
640 reverse = -1;
641 gNewTireSpin = "BackwardSpin";
642 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
643 }
644 if(~held & change & CONTROL_FWD){
645 //llSay(0,"CONTROL_FWD:Released");
646 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
647 gNewTireSpin = "NoSpin";
648 gNewTurnAngle = "NoTurn";
649
650 if(gGear > 9){
651 gGear = 3;
652 }
653
654 }
655 if(~held & change & CONTROL_BACK){
656 //llSay(0,"CONTROL_BACK:Released");
657 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
658 gNewTireSpin = "NoSpin";
659 gNewTurnAngle = "NoTurn";
660 }
661 if(~held & ~change & CONTROL_FWD){
662 //llSay(0,"CONTROL_FWD:Inactive");
663 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
664 }
665 if(~held & ~change & CONTROL_BACK){
666 //llSay(0,"CONTROL_BACK:Inactive");
667 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
668 }
669
670 showdata("Speed Vector:" + (string)speedvec + " Speed:" + (string)(gSpeed*2.23692912) + " mph");
671 enginesound();
672
673 vector AngularMotor;
674 if(held & (CONTROL_ROT_RIGHT)){
675 if(gGear==0){
676 AngularMotor.z -= 1.5*gTurnMulti;
677 }else{
678 AngularMotor.x += 1.5*gTurnMulti;
679 }
680 gNewTurnAngle = "RightTurn";
681 gTurnCount = 10;
682 gTcountR = 2;
683 }
684
685 if(held & (CONTROL_ROT_LEFT)){
686 if(gGear==0){
687 AngularMotor.z += 1.5*gTurnMulti;
688 }else{
689 AngularMotor.x -= 1.5*gTurnMulti;
690 }
691 gNewTurnAngle = "LeftTurn";
692 gTurnCount = 10;
693 gTcountL = 2;
694 }
695
696 // going up or stop going up
697 if(held & CONTROL_UP) {
698 if(gGear!=0){
699 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <gGearPower,0,gVerticalThrust*gGear>);
700 }else{
702 }
703 } else if(change & CONTROL_UP) {
704 if(gGear!=0){
706 }else{
708 }
709 }
710
711 // going down or stop going down
712
713 if(held & CONTROL_DOWN) {
714 if(gGear!=0){
715 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <gGearPower,0,-gVerticalThrust*gGear>);
716 }else{
718 }
719 } else if(change & CONTROL_DOWN) {
720 if(gGear!=0){
722 }else{
724 }
725 }
726
727 AngularMotor.y = 0;
728
730 if(gTcountL > 0){
731 gTcountL--;
732 //llSay(0,(string)gTcountL);
733 }
734 if(gTcountL == 1){
735 cornerFXL();
736 }
737 if(gTcountR > 0){
738 gTcountR--;
739 // llSay(0,(string)gTcountR);
740 }
741 if(gTcountR == 1){
742 cornerFXR();
743 }
744
745 if(gTurnCount > 0){
746 gTurnCount--;
747 }
748 if(gTurnCount == 1){
749 gNewTurnAngle = "NoTurn";
750 }
751 if(gTurnAngle != gNewTurnAngle){
752 gTurnAngle = gNewTurnAngle;
754 }
755 if(gTireSpin != gNewTireSpin){
756 gTireSpin = gNewTireSpin;
758 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
759 }
760
761 }
762
763 touch_start(integer total_number){
764 if(gAgent != NULL_KEY){
765 menu(llDetectedKey(0), "\nDriver's Menu.", MENU_MAIN);
766 }
767 }
768
769 listen(integer channel,string name,key id,string message){
770 if(channel == menu_channel){
771 llListenRemove(menu_handler);
773 if(message == "Align"){
774 llSay(0, "Car is lined up...");
775 nearestpi();
776 }
777 else if(message == "Hello"){
778 llSay(0, "Hello yourself");
779 }
780 // else if(message == "Button"){
781 // do something
782 //}
783 }
784 }
785
786
787 link_message(integer sender, integer num, string str, key id){
788
789 integer i = llGetLinkNumber() != 0; // Start at zero (single prim) or 1 (two or more prims)
790 integer x = llGetNumberOfPrims() + i; // [0, 1) or [1, llGetNumberOfPrims()]
791
792 for (; i < x; ++i)
793 {
794
795 if(llGetLinkName(i) == "spin"){
796 rotation rootRot = llGetRootRotation();
797 vector rootPos = llGetRootPosition();
798
799 list params = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL,PRIM_SIZE]);
800 rotation childRot = llList2Rot(params,1);
801 vector childPos = (llList2Vector(params,0)-rootPos)/rootRot;
802 vector childSize = llList2Vector(params,2);
803
804 if(str == "ForwardSpin"){
805 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, TWO_PI, 1.0]);
806 }else if(str == "BackwardSpin"){
807 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, -TWO_PI, 1.0]);
808 }else if(str == "NoSpin"){
809 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*childRot, 0, 1.0]);
810 }
811 }else if(llGetLinkName(i) == "spin_y"){
812 if(str == "NoRotate"){
813 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
814 }else if(str == "SlowRotate"){
815 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
816 }else if(str == "FastRotate"){
817 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
818 }
819 }else if(llGetLinkName(i) == "spin_x"){
820 if(str == "NoRotate"){
821 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
822 }else if(str == "SlowRotate"){
823 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <90.0,0.0,0.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
824 }else if(str == "FastRotae"){
825 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <90.0,0.0,0.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
826 }
827 }else if(llGetLinkName(i) == "spin_z"){
828 if(str == "NoRotate"){
829 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
830 }else if(str == "SlowRotate"){
831 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,0.0,90.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
832 }else if(str == "FastRotate"){
833 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,0.0,90.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
834 }
835
836 }
837 }
838 }
839
840 timer(){
841 llListenRemove(menu_handler);
842 if(gRun == 1){
843
844 }else{
845 llSetTimerEvent(0.0);
846 }
847 }
848 }

Back to the Best Free Tools in Second Life and OpenSim.