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 JetBike  

Opensim Bulletsim JetBike

The jetbike is a flyer so it will climb or dive and taxi very fast. You can use it like a bike and have the option to pull up when you find your self in a bind.

Category: Vehicle
By : Shin Ingen @ http://ingen-lab.com:8002
Created: 2014-09-08 Edited: 2014-09-08
Worlds: OpenSim

the Zip file

Download all files for Opensim Bulletsim JetBike
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1
2 //*******************************************************
3 // Shin Ingen @ http://ingen-lab.com:8002
4 // LSL | OPENSIM | BulletSim | JetBike v1.0
5 // iTEC + e3s + DC (ENGINE SPEED SENSITIVE STEERING WITH DYNAMIC CAMERA)
6 // JANUARY 28, 2013
7 // TODO: KEYWORD PROCESSOR FOR ** PRIM ANIMATION | AVATAR ANIMATION | SOUNDS | MENU | HUD | DYNAMIC CAMERA
8 //*******************************************************
9
10 //---PERMISSION VARIABLES---------------------------------------------
11 integer gDrivePermit = 1; // 0=EVERYONE 1=OWNERONLY
12 string gSitMessage = "Drive";
13 string gUrNotAllowedMessage = "Vehicle is Locked";
14 vector gSitTarget_Pos = <0.3,0.02,0.95>;
15 vector gSitTarget_Rot;
16 key gOldAgent;
17 key gAgent;
18 integer gRun; //ENGINE RUNNING
19 integer gMoving; //VEHICLE MOVING
20 //integer gIdle;
21 //---END PREMISSION----------------------------------------------------
22
23 //---ANIMATION VARIABLES-----------------------------------------------
24 string gDrivingAnim = "motorcycle_sit";
25 //---------------------------------------------------------------------
26
27 //---CAMERA VARIABLES--------------------------------------------------
28 //***CONSTANT**********************************************************
29 integer gCamFixed=0; // INITVAL=0 0=FOLLOW CAM 1=FIXED CAM
30 //integer gCamAct; // INITVAL=1 0=INACTIVE 1=ACTIVE
31 //integer gCamFocLocked; // INITVAL=FALSE (TRUE or FALSE)
32 //integer gCamPoslocked; // INITVAL=FALSE (TRUE or FALSE)
33 //***SLIDERS***********************************************************
34 //float gCamBAng; // INITVAL=2.0 (0 to 180) DEGREES
35 //float gCamBLag; // INITVAL=0.1 (0 to 3) SECONDS
36 //float gCamDist; // INITVAL=8.0 (0.5 to 10) METERS
37 //float gCamFocLag; // INITVAL=0.1 (0 to 3) SECONDS
38 //float gCamFocThresh; // INITVAL=0.5 (0 to 4) METERS
39 //float gCamPitch; // INITVAL=20.0 (-45 to 80) DEGREES
40 //float gCamPoslag; // INITVAL=0.1 (0 to 3) SECONDS
41 //float gCamPosthresh; // INITVAL=0.5 (0 to 4) METERS
42 //vector gCamFocOff; // INITVAL=<0.10,0,0> <-10,-10,-10> to <10,10,10> METERS
43 //----END CAMERA-------------------------------------------------------
44
45 //---SOUND VARIABLES---------------------------------------------------
46 string gSoundFlight = "s_flight";
47 string gSoundHorn = "s_horn";
48 string gSoundStartup = "Ducati-start2";
49 string gSoundIdle = "Ducati-idle2";
50 string gSoundSlow = "Ducati-run";
51 string gSoundAggressive = "Ducati-runfast";
52 string gSoundGearUp = "Ducati-accelerate";
53 string gSoundGearDown = "Ducati-accelerate";
54 string gSoundRev = "s_rev";
55 string gSoundAlarm = "s_alarm";
56 string gSoundStop = "Ducati-off";
57 //NEED KEYWORD SOUND PROCESSOR
58 integer gOldSound=3; //variable for sound function
59 integer gNewSound=3;
60 //---------------------------------------------------------------------
61
62 //---iTEC - STOCK ENGINE GLOBAL VARIABLES------------------------------
63 list gTSvarList;
64 float gVLMT=0.90; //INITVAL=0.90
65 float gVLMDT=0.10; //INITVAL=0.10
66 vector gVLFT=<8.0, 3000.0, 8.0>; //INITVAL=<8.0, 3000.0, 8.0>
67 vector gVAFT=<0.10, 0.10, 0.10>; //INITVAL=<0.10, 0.10, 0.10>
68 float gVADE=0.20; //INITVAL=0.20
69 float gVADT=0.50; //INITVAL=0.10
70 float gVAMT=1.0; //INITVAL=0.10
71 float gVAMDT=0.10; //INITVAL=0.10
72 float gVLDE=1.0; //INITVAL=1.0
73 float gVLDT=0.10; //INITVAL=0.10
74 float gVVAE=0.50; //INITVAL=0.50
75 float gVVAT=5.0; //INITVAL=5.0
76 float gVHE=0.0; //INITVAL=0.0
77 float gVHT=0.0; //INITVAL=0.0
78 float gVHH=0.0; //INITVAL=0.0
79 float gVB=0.0; //INITVAL=0.0
80 float gVBE=1.0; //INITVAL=1.0
81 float gVBM=0.5; //INITVAL=0.5
82 float gVBT=0.5; //INITVAL=0.5
83 float gVerticalThrust=10.0;
84 //---------------------------------------------------------------------
85
86 //---iTEC POWERTRAIN + (e3s) GLOBAL VARIABLES -------------------------
87 integer gGear;
88 integer gNewGear;
89 float gGearPower;
90 float gReversePower = -15;
91 list gGearPowerList = [ 2, // STAGER
92 15, // BURNOUT
93 20, // 1ST
94 40, // 2ND
95 70, // 3RD
96 80, // 4TH
97 100, // 5TH
98 110, // 6TH
99 155, // PRO-STOCK (START-DRAG-CLASS)
100 170, // PRO-MOD
101 198, // TOP-FUEL
102 256 // OPEN-PRO
103 ];
104 //integer gGearCount;
105 string gPhysEngDesc;
106 integer gPhysEng=1; // if os function is off set this to 0=ODE| 1=Bullet
107 float gTurnMulti=1.012345;
108 float gTurnRatio;
109 list gTurnRatioList;
110 string gGearName;
111 list gGearNameList =[ "STAGER",
112 "BURNOUT",
113 "1ST-GEAR",
114 "2ND-GEAR",
115 "3RD-GEAR",
116 "4TH-GEAR",
117 "5TH-GEAR",
118 "6TH-GEAR",
119 "PRO-STOCK",
120 "PRO-MOD",
121 "TOP-FUEL",
122 "OPEN-PRO"
123 ];
124 float gSpeed=0;
125 //---------------------------------------------------------------------
126
127 //---------------------------------------------------------------------
128 //NEED A KEYWORD PRIM ANIMATION PROCESSOR
129 integer gTurnCount;
130 string gTurnAngle = "NoTurn"; // LeftTurn or RightTurn or NoTurn
131 string gNewTurnAngle = "NoTurn";
132 string gTireSpin = "ForwardSpin"; // ForwardSpin or BackwardSpin or NoSpin
133 string gNewTireSpin = "ForwardSpin";
134 string gRotorSpin = "NoRotate"; // NoRotate or SlowRotate or FastRotate
135 integer gTcountL; //for cornerF
136 Xinteger gTcountR;
137
138 //---------------------------------------------------------------------
139
140 //---MENU HANDLER------------------------------------------------------
141 list MENU_MAIN = ["Align", "Hello"]; // up to 12 items in list
142 integer menu_handler;
143 integer menu_channel;
144 //---------------------------------------------------------------------
145
146 //=======================================================================
147 //==== 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 ====
148 //=======================================================================
149 init_TSvar(integer i){
150 if(i==0){
151 gTSvarList = [ 3.0, // how fast to reach max speed
152 0.10, // how fast to reach min speed or zero
153 <7.0,3000.0,100.0>, // XYZ linear friction
154 <0.10,0.10,0.20>, // XYZ angular friction
155 0.90, // how fast turning force is applied
156 0.50, // how fast turning force is released
157 1.0, // adjusted on 0.7.6
158 0.10,
159 0.20,
160 0.10,
161 0.50,
162 5.0,
163 0.0,
164 0.0,
165 0.0,
166 0.0
167 ];
168 }else{
169 gTSvarList = [
170 0.90, // 0
171 0.10, // 1
172 <1.0,1.0,1.0>, // 2
173 <1.0,1000.0,1000.0>, // 3
174 0.20, // 4
175 0.10, // 5
176 0.10, // 6
177 10.00, // 7
178 0.10, // 8
179 10.00, // 9
180 3.00, // 10
181 2.00, // 11
182 0.0, // 12
183 0.0, // 13
184 0.0, // 14
185 0.0, // 15
186 1.0, // 16
187 1.0, // 17
188 0.5 // 18
189 ];
190 }
191 gVLMT=llList2Float(gTSvarList,0);
192 gVLMDT=llList2Float(gTSvarList,1);
193 gVLFT=llList2Vector(gTSvarList,2);
194 gVAFT=llList2Vector(gTSvarList,3);
195 gVAMT=llList2Float(gTSvarList,4);
196 gVAMDT=llList2Float(gTSvarList,5);
197 gVLDE=llList2Float(gTSvarList,6);
198 gVLDT=llList2Float(gTSvarList,7);
199 gVADE=llList2Float(gTSvarList,8);
200 gVADT=llList2Float(gTSvarList,9);
201 gVVAE=llList2Float(gTSvarList,10);
202 gVVAT=llList2Float(gTSvarList,11);
203 gVHE=llList2Float(gTSvarList,12);
204 gVHT=llList2Float(gTSvarList,13);
205 gVHH=llList2Float(gTSvarList,14);
206 gVB=llList2Float(gTSvarList,15);
207 gVBE=llList2Float(gTSvarList,16);
208 gVBM=llList2Float(gTSvarList,17);
209 gVBT=llList2Float(gTSvarList,18);
210
211 }
212
213 init_PhysEng(){
214 string msg;
215
216 //gPhysEngDesc=osGetPhysicsEngineType();
217 //if(gPhysEngDesc=="OpenDynamicsEngine"){
218 // msg =":: is tuned for OpenDynamicsEngine";
219 // gPhysEng=0;
220 //}else if(gPhysEngDesc=="BulletSim"){
221 // msg =":: is tuned for BulletSim";
222 // gPhysEng=1;
223 //}else{
224 // msg ="WARNING:Automatic Detection of Physics Engine is off.";
225 //}
226
227 if(gPhysEng==0){
228 msg =":: is tuned for OpenDynamicsEngine";
229 }else if(gPhysEng==1){
230 msg =":: is tuned for BulletSim";
231 }
232
233 if(gPhysEng==0){
234 gTurnMulti=gTurnMulti;
235 init_TSvar(0);
236 gTurnRatioList = [ 2.4, // STAGER
237 2.4, // BURNOUT
238 2.4, // 1ST
239 2.5, // 2ND
240 4.5, // 3RD
241 5.0, // 4TH
242 5.5, // 5TH
243 6.5, // 6TH
244 7.5, // PRO-STOCK (START-DRAG-CLASS)
245 10.0, // PRO-MOD
246 10.0, // TOP-FUEL
247 10.0 // OPEN-PRO
248 ];
249 gGearPowerList = [ 2, // STAGER
250 10, // BURNOUT
251 15, // 1ST
252 50, // 2ND
253 70, // 3RD
254 85, // 4TH
255 100, // 5TH
256 110, // 6TH
257 155, // PRO-STOCK (START-DRAG-CLASS)
258 170, // PRO-MOD
259 200, // TOP-FUEL
260 256 // OPEN-PRO
261 ];
262
263
264 }else{
265 gTurnMulti=1.12345;
266 init_TSvar(1);
267 gTurnRatioList = [ 1.1, // STAGER
268 1.2, // BURNOUT
269 1.5, // 1ST
270 1.6, // 2ND
271 2.0, // 3RD
272 2.1, // 4TH
273 2.1, // 5TH
274 2.1, // 6TH
275 2.1, // PRO-STOCK (START-DRAG-CLASS)
276 2.1, // PRO-MOD
277 2.1, // TOP-FUEL
278 2.1 // OPEN-PRO
279 ];
280
281 gGearPowerList = [ 2, // STAGER
282 15, // BURNOUT
283 30, // 1ST
284 60, // 2ND
285 80, // 3RD
286 90, // 4TH
287 100, // 5TH
288 110, // 6TH
289 155, // PRO-STOCK (START-DRAG-CLASS)
290 170, // PRO-MOD
291 198, // TOP-FUEL
292 256 // OPEN-PRO
293 ];
294
295 }
296 llSay(0,msg);
297 }
298
299 preload_sounds(){
300 llPreloadSound(gSoundFlight);
301 llPreloadSound(gSoundHorn);
302 llPreloadSound(gSoundStartup);
303 llPreloadSound(gSoundIdle);
304 llPreloadSound(gSoundSlow);
305 llPreloadSound(gSoundAggressive);
306 llPreloadSound(gSoundGearUp);
307 llPreloadSound(gSoundGearDown);
308 llPreloadSound(gSoundRev);
309 llPreloadSound(gSoundAlarm);
310 }
311
312 init_engine(){
313 gRun = 0;
314 llSetSitText(gSitMessage);
315 llCollisionSound("", 0.0);
316 gSitTarget_Rot = llRot2Euler( llGetRootRotation() ); // SIT TARGET IS BASED ON VEHICLE'S ROTATION.
317 llSitTarget(gSitTarget_Pos, llEuler2Rot(DEG_TO_RAD * gSitTarget_Rot));
318 gOldSound=3;
319 gNewSound=3;
320 gTireSpin = "NoSpin";
321 gTurnAngle = "NoTurn";
322 gRotorSpin = "NoRotate";
323 llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
324 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY); // NO SPIN
325 llMessageLinked(LINK_SET, 0, gTurnAngle, NULL_KEY); // NO TURN
326 llMessageLinked(LINK_SET, 0, gRotorSpin, NULL_KEY); // SLOW SPIN
327 }
328
329 init_followCam(){
331 CAMERA_ACTIVE, 1, // 0=INACTIVE 1=ACTIVE
332 CAMERA_BEHINDNESS_ANGLE, 2.5, // (0 to 180) DEGREES
333 CAMERA_BEHINDNESS_LAG, 0.3, // (0 to 3) SECONDS
334 CAMERA_DISTANCE, 6.0, // ( 0.5 to 10) METERS
335 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 12.0, // (-45 to 80) DEGREES
336 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
337 CAMERA_POSITION_LAG, 0.0, // (0 to 3) SECONDS
338 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) METERS
339 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
340 CAMERA_FOCUS_LAG, 0.0, // (0 to 3) SECONDS
341 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) METERS
342 CAMERA_FOCUS_OFFSET, <0.0,0,0> // <-10,-10,-10> to <10,10,10> METERS
343 ]);
345 }
346
347 init_fixedCam(float degrees) {
348 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
349 llSetCameraEyeOffset(<-10, 0, 3.5> * sitRot);
350 llSetCameraAtOffset(<4, 0, 3> * sitRot);
352 }
353
354 set_engine(){
360 llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0.00000, 0.00000, 0.00000, 0.00000>);
361 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, gVLMT);
366 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, gVAMDT);
380
381 // llRemoveVehicleFlags(vfW); // NOT FOR OPENSIM
382 // llRemoveVehicleFlags(vfA); // NOT FOR OPENSIM
383 //llSetVehicleFlags(vfG); // NOT FOR OPENSIM
384 gRotorSpin = "SlowRotate";
385 llMessageLinked(LINK_SET, 0, gRotorSpin, NULL_KEY); // SLOW SPIN
386 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
387 }
388
389 powershift(integer g){
390 if(!gMoving){
391 if(gCamFixed==0){
394 }
395 }
396 else {
397 vector vel = llGetVel();
398 float speed = llVecMag(vel);
399 if(speed <=20){
400 if(gCamFixed==0){
403 }
404 }
405 else if((speed >=21) || (speed <=50)){
406 if(gCamFixed==0){
409 }
410 }
411 else if(speed >=51) {
412 if(gCamFixed==0){
415 }
416
417 }
418 }
419 gGearPower = llList2Integer(gGearPowerList, g);
420 }
421
422 gearshift(integer g){
423 gGearName = llList2String(gGearNameList, g);
424 enginesound();
425 llSay(0,gGearName);
426 }
427
428 nearestpi(){
429 // ALIGNS THE VEHICLE EAST WEST SOUTH NORTH BASED ON CURRENT ROTATION (PRESTAGE AND STAGE DURING DRAG MODE)
431 llSetRot( llEuler2Rot( <Rad.x, Rad.y, llRound( Rad.z / PI_BY_TWO ) * PI_BY_TWO > ) );
432 }
433
434 menu(key user,string title,list buttons)
435 {
436 llListenRemove(menu_handler);
437 menu_channel = (integer)(llFrand(99999.0) * -1);
438 menu_handler = llListen(menu_channel,"","","");
439 llDialog(user,title,buttons,menu_channel);
440 llSetTimerEvent(30.0);
441 }
442
443 showdata(string s){
444 llSetText(s+"\n.\n.\n.\n.",<1,1,.6>,1.0);
445 //llSetText("",<0,0,0>,1.0);
446 }
447
448 enginesound(){
449 vector vel = llGetVel();
450 float speed = llVecMag(vel);
451 if(speed <=10){
452 gNewSound = 0;
453 }
454 else if(speed >=50){
455 gNewSound = 2;
456 }
457 else {
458 gNewSound = 1;
459 }
460
461 if(gOldSound != gNewSound){
462 if(speed <=10){
463 llLoopSound(gSoundIdle,1.0);
464 }
465 else if(speed >=50){
466 llLoopSound(gSoundAggressive,1.0);
467 }
468 else {
469 llLoopSound(gSoundSlow,1.0);
470 }
471 gOldSound = gNewSound;
472 }
473 }
474
475 cornerFXR(){
476 vector vel = llGetVel();
477 float speed = llVecMag(vel);
478 if(speed >50){
479 llMessageLinked(LINK_SET, 0, "letsburnR", NULL_KEY);
480 }
481 }
482
483 cornerFXL(){
484 vector vel = llGetVel();
485 float speed = llVecMag(vel);
486 if(speed >50){
487 llMessageLinked(LINK_SET, 0, "letsburnL", NULL_KEY);
488 }
489 }
490
491 default {
493 {
494 init_engine();
495 state Ground;
496 }
497 }
498
499 state Ground{
500
502 }
503 on_rez(integer param) {
505 preload_sounds();
506 init_PhysEng();
507 }
508
509 changed(integer change){
510 if((change & CHANGED_LINK) == CHANGED_LINK){
511 gAgent = llAvatarOnSitTarget();
512 if(gAgent != NULL_KEY){
513 if( (gAgent != llGetOwner()) && (gDrivePermit == 1)){
514 llSay(0, gUrNotAllowedMessage);
515 llUnSit(gAgent);
516 llPlaySound(gSoundAlarm,1.0);
517 llPushObject(gAgent, <3,3,20>, ZERO_VECTOR, FALSE);
518 }
519 else {
521 llSetStatus(STATUS_ROTATE_Y,TRUE);
522 llSetStatus(STATUS_ROTATE_Z,TRUE);
523 gOldAgent = gAgent;
524 init_PhysEng();
525 set_engine();
527 gRun = 1;
528 }
529 }
530 else {
531 llSetStatus(STATUS_PHYSICS, FALSE); //SHOULD THIS BE THE LAST THING YOU SET??
532 gRun = 0;
533 //init_PhysEng();
534 init_engine();
535 llTriggerSound(gSoundStop,1);
536 llStopAnimation(gDrivingAnim);
537 llPushObject(gAgent, <3,3,20>, ZERO_VECTOR, FALSE);
538 llSetTimerEvent(0.0);
542 llSetCameraParams([CAMERA_ACTIVE, 0]);
543 llSetText("",<0,0,0>,1.0);
544 }
545 }
546 }
548 if(perm) {
549 gGear = 2; // GEAR#0 IS STAGER | GEAR#1 IS BURNOUT | GEAR#2 IS THE FIRST GEAR (LIST INDEX STARTS @ 0)
550 //gNewGear = 2;
552 if(gCamFixed == 1) {
553 init_fixedCam(0);
554 }else{
555 init_followCam();
556 }
557 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
558 llMessageLinked(LINK_SET, 0, "headlight", "0");
559 llStartAnimation(gDrivingAnim);
560 llTriggerSound(gSoundStartup,1.0);
561 llSleep(1.5);
562 enginesound();
563 }
564 }
565
566 control(key id, integer held, integer change){
567 if(gRun == 0){
568 return;
569 }
570 integer reverse=1;
571 vector vel = llGetVel();
572 vector speedvec = llGetVel() / llGetRot();
573 gSpeed = llVecMag(vel);
574 gTurnRatio = llList2Float(gTurnRatioList,gGear);
575
576 if((held & change & CONTROL_RIGHT) || ((gGear >= 11) && (held & CONTROL_RIGHT))){
577 gGear=gGear+1;
578 if(gGear < 0) gGear = 0;
579 if(gGear > 11) gGear = 11;
580 gearshift(gGear);
581 }
582
583 if((held & change & CONTROL_LEFT) || ((gGear >= 11) && (held & CONTROL_LEFT))){
584 gGear=gGear-1;
585 if(gGear < 0) gGear = 0;
586 if(gGear > 11) gGear = 11;
587 gearshift(gGear);
588
589 }
590
591 if(held & CONTROL_FWD){
592 if(gGear == 0) {
594 }else{
596 }
597 if(gGear == 1) {
598 //llMessageLinked(LINK_SET, 0, "letsburn", NULL_KEY);
599 //llMessageLinked(LINK_SET, 0, "letsscreech", NULL_KEY);
600 //llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
601 }
602 if(gGear == 2) {
603 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
604 }
605 if(gGear == 3) {
606 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
607 }
608 if(gGear == 4) {
609 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
610 }
611 if(gGear == 5) {
612 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
613 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
614 }
615 if(gGear == 6) {
616 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
617 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
618 }
619 if(gGear == 7) {
620 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
621 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
622 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
623 }
624 if(gGear == 8) {
625 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
626 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
627 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
628 }
629 if(gGear == 9) {
630 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
631 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
632 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
633 }
634 if(gGear == 10) {
635 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
636 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
637 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
638 }
639 if(gGear == 11) {
640 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
641 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
642 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
643 }
644 powershift(gGear);
646 gMoving=1;
647 reverse=1;
648 gNewTireSpin = "ForwardSpin";
649
650 }
651
652 if(held & CONTROL_BACK){
656 gTurnRatio = -2.0;
657 reverse = -1;
658 gNewTireSpin = "BackwardSpin";
659 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
660 }
661 if(~held & change & CONTROL_FWD){
662 //llSay(0,"CONTROL_FWD:Released");
663 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
664 gNewTireSpin = "NoSpin";
665 gNewTurnAngle = "NoTurn";
666
667 if(gGear > 9){
668 gGear = 3;
669 }
670
671 }
672 if(~held & change & CONTROL_BACK){
673 //llSay(0,"CONTROL_BACK:Released");
674 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
675 gNewTireSpin = "NoSpin";
676 gNewTurnAngle = "NoTurn";
677 }
678 if(~held & ~change & CONTROL_FWD){
679 //llSay(0,"CONTROL_FWD:Inactive");
680 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
681 }
682 if(~held & ~change & CONTROL_BACK){
683 //llSay(0,"CONTROL_BACK:Inactive");
684 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
685 }
686
687 showdata("Speed Vector:" + (string)speedvec + " Speed:" + (string)(gSpeed*2.23692912) + " mph");
688 enginesound();
689
690 vector AngularMotor;
691 AngularMotor.y = 0;
692 if(held & (CONTROL_ROT_RIGHT)){
693 if(gGear<3){
694 AngularMotor.x += ((gTurnRatio/gTurnMulti)*1);
695 AngularMotor.z -= ((gTurnRatio*gTurnMulti)/1);
696 }else if(gGear==3){
697 AngularMotor.x += ((gTurnRatio/gTurnMulti)*1);
698 AngularMotor.z -= ((gTurnRatio/gTurnMulti)/2);
699 }else{
700 AngularMotor.x += ((gTurnRatio/gTurnMulti)*1);
701 AngularMotor.z -= ((gTurnRatio/gTurnMulti)/8);
702 }
703 gNewTurnAngle = "RightTurn";
704 gTurnCount = 10;
705 gTcountR = 2;
706 }
707
708 if(held & (CONTROL_ROT_LEFT)){
709 if(gGear<3){
710 AngularMotor.x -= ((gTurnRatio/gTurnMulti)*1);
711 AngularMotor.z += ((gTurnRatio*gTurnMulti)/1);
712 }else if(gGear==3){
713 AngularMotor.x -= ((gTurnRatio/gTurnMulti)*1);
714 AngularMotor.z += ((gTurnRatio/gTurnMulti)/2);
715 }else{
716 AngularMotor.x -= ((gTurnRatio/gTurnMulti)*1);
717 AngularMotor.z += ((gTurnRatio/gTurnMulti)/8);
718 }
719 gNewTurnAngle = "LeftTurn";
720 gTurnCount = 10;
721 gTcountL = 2;
722 }
723 // going up or stop going up
724 if(held & CONTROL_UP) {
725 if(gGear!=0){
726 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <gGearPower,0,gVerticalThrust*gGear>);
727 AngularMotor.y -= 0.5; //((gTurnRatio/gTurnMulti)*1);
728 }else{
730 }
731 } else if(change & CONTROL_UP) {
732 if(gGear!=0){
734 AngularMotor.y = 0;
735 }else{
737 }
738 }
739
740 // going down or stop going down
741
742 if(held & CONTROL_DOWN) {
743 if(gGear!=0){
744 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <gGearPower,0,-gVerticalThrust*gGear>);
745 AngularMotor.y += 0.5; //((gTurnRatio/gTurnMulti)*1);
746 }else{
748 }
749 } else if(change & CONTROL_DOWN) {
750 if(gGear!=0){
752 AngularMotor.y = 0;
753 }else{
755 }
756 }
758 if(gTcountL > 0){
759 gTcountL--;
760 //llSay(0,(string)gTcountL);
761 }
762 if(gTcountL == 1){
763 cornerFXL();
764 }
765 if(gTcountR > 0){
766 gTcountR--;
767 // llSay(0,(string)gTcountR);
768 }
769 if(gTcountR == 1){
770 cornerFXR();
771 }
772
773 if(gTurnCount > 0){
774 gTurnCount--;
775 }
776 if(gTurnCount == 1){
777 gNewTurnAngle = "NoTurn";
778 }
779 if(gTurnAngle != gNewTurnAngle){
780 gTurnAngle = gNewTurnAngle;
782 }
783 if(gTireSpin != gNewTireSpin){
784 gTireSpin = gNewTireSpin;
786 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
787 }
788
789 }
790
791 touch_start(integer total_number){
792 if(gAgent != NULL_KEY){
793 menu(llDetectedKey(0), "\nDriver's Menu.", MENU_MAIN);
794 }
795 }
796
797 listen(integer channel,string name,key id,string message){
798 if(channel == menu_channel){
799 llListenRemove(menu_handler);
801 if(message == "Align"){
802 llSay(0, "Car is lined up...");
803 nearestpi();
804 }
805 else if(message == "Hello"){
806 llSay(0, "Hello yourself");
807 }
808 // else if(message == "Button"){
809 // do something
810 //}
811 }
812 }
813
814
815 link_message(integer sender, integer num, string str, key id){
816
817 integer i = llGetLinkNumber() != 0; // Start at zero (single prim) or 1 (two or more prims)
818 integer x = llGetNumberOfPrims() + i; // [0, 1) or [1, llGetNumberOfPrims()]
819
820 for (; i < x; ++i)
821 {
822
823 if(llGetLinkName(i) == "spin")
824 {
825 rotation rootRot = llGetRootRotation();
826 vector rootPos = llGetRootPosition();
827
828 list params = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL,PRIM_SIZE]);
829 rotation childRot = llList2Rot(params,1);
830 vector childPos = (llList2Vector(params,0)-rootPos)/rootRot;
831 vector childSize = llList2Vector(params,2);
832
833 if(str == "ForwardSpin"){
834 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, TWO_PI, 2.0]);
835 }else if(str == "BackwardSpin"){
836 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, -TWO_PI, 1.0]);
837 }else if(str == "NoSpin"){
838 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*childRot, 0, 1.0]);
839 }
840 }else if(llGetLinkName(i) == "spin_y"){
841 if(str == "NoRotate"){
842 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
843 }else if(str == "SlowRotate"){
844 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
845 }else if(str == "FastRotate"){
846 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
847 }
848 }else if(llGetLinkName(i) == "spin_x"){
849 if(str == "NoRotate"){
850 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
851 }else if(str == "SlowRotate"){
852 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <90.0,0.0,0.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
853 }else if(str == "FastRotate"){
854 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <90.0,0.0,0.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
855 }
856 }else if(llGetLinkName(i) == "spin_z"){
857 if(str == "NoRotate"){
858 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
859 }else if(str == "SlowRotate"){
860 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,0.0,90.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
861 }else if(str == "FastRotate"){
862 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,0.0,90.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
863 }
864 }
865 }
866 }
867
868 timer(){
869 llListenRemove(menu_handler);
870 if(gRun == 1){
871
872 }else{
873 llSetTimerEvent(0.0);
874 }
875 }
876 }

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