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 Motorbike  

Opensim Bulletsim Motorbike

Opensim Bullety Physics Motorcycle

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 Motorbike
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1
2 //Controls:
3
4 //Page Up & Page Down Keys: Wheelie and Backward Wheelie
5 //Shift+Left and Shift+Right Arrow Keys: shift your gears up and down
6 //Up and Down Arrow Keys: Forward and Reverse
7 //Left and Right Arrow Keys: Turning Gears are 2nd and 3rd for your tight turns and 4th and 5th for your wide leaning turns. Holding down the left or right arrow keys increases your lean so let it go to recover. For the most part, the angular deflection is where you will have to customize the script to compliment your driving style and driving environment. The settings I have in both of these scripts are for my var region where roads are 60 meters wide and goes to the full length of the 2048 varregion sim.
8
9 //*******************************************************
10 // Shin Ingen @ http://ingen-lab.com:8002
11 // LSL | OPENSIM | BulletSim | Motorbike v1.0
12 // iTEC + e3s + DC (ENGINE SPEED SENSITIVE STEERING WITH DYNAMIC CAMERA)
13 // JANUARY 28, 2013
14 // TODO: KEYWORD PROCESSOR FOR ** PRIM ANIMATION | AVATAR ANIMATION | SOUNDS | MENU | HUD | DYNAMIC CAMERA
15 //*******************************************************
16
17 //---PERMISSION VARIABLES---------------------------------------------
18 integer gDrivePermit = 1; // 0=EVERYONE 1=OWNERONLY
19 string gSitMessage = "Drive";
20 string gUrNotAllowedMessage = "Vehicle is Locked";
21 vector gSitTarget_Pos = <0.2,0.02,0.75>;
22 vector gSitTarget_Rot;
23 key gOldAgent;
24 key gAgent;
25 integer gRun; //ENGINE RUNNING
26 integer gMoving; //VEHICLE MOVING
27 //integer gIdle;
28 //---END PREMISSION----------------------------------------------------
29
30 //---ANIMATION VARIABLES-----------------------------------------------
31 string gDrivingAnim = "motorcycle_sit";
32 //---------------------------------------------------------------------
33
34 //---CAMERA VARIABLES--------------------------------------------------
35 //***CONSTANT**********************************************************
36 integer gCamFixed=0; // INITVAL=0 0=FOLLOW CAM 1=FIXED CAM
37 //integer gCamAct; // INITVAL=1 0=INACTIVE 1=ACTIVE
38 //integer gCamFocLocked; // INITVAL=FALSE (TRUE or FALSE)
39 //integer gCamPoslocked; // INITVAL=FALSE (TRUE or FALSE)
40 //***SLIDERS***********************************************************
41 //float gCamBAng; // INITVAL=2.0 (0 to 180) DEGREES
42 //float gCamBLag; // INITVAL=0.1 (0 to 3) SECONDS
43 //float gCamDist; // INITVAL=8.0 (0.5 to 10) METERS
44 //float gCamFocLag; // INITVAL=0.1 (0 to 3) SECONDS
45 //float gCamFocThresh; // INITVAL=0.5 (0 to 4) METERS
46 //float gCamPitch; // INITVAL=20.0 (-45 to 80) DEGREES
47 //float gCamPoslag; // INITVAL=0.1 (0 to 3) SECONDS
48 //float gCamPosthresh; // INITVAL=0.5 (0 to 4) METERS
49 //vector gCamFocOff; // INITVAL=<0.10,0,0> <-10,-10,-10> to <10,10,10> METERS
50 //----END CAMERA-------------------------------------------------------
51
52 //---SOUND VARIABLES---------------------------------------------------
53 string gSoundFlight = "s_flight";
54 string gSoundHorn = "s_horn";
55 string gSoundStartup = "Ducati-start2";
56 string gSoundIdle = "Ducati-idle2";
57 string gSoundSlow = "Ducati-run";
58 string gSoundAggressive = "Ducati-runfast";
59 string gSoundGearUp = "Ducati-accelerate";
60 string gSoundGearDown = "Ducati-accelerate";
61 string gSoundRev = "s_rev";
62 string gSoundAlarm = "s_alarm";
63 string gSoundStop = "Ducati-off";
64 //NEED KEYWORD SOUND PROCESSOR
65 integer gOldSound=3; //variable for sound function
66 integer gNewSound=3;
67 //---------------------------------------------------------------------
68
69 //---iTEC - STOCK ENGINE GLOBAL VARIABLES------------------------------
70 list gTSvarList;
71 float gVLMT=0.90; //INITVAL=0.90
72 float gVLMDT=0.10; //INITVAL=0.10
73 vector gVLFT=<8.0, 3000.0, 8.0>; //INITVAL=<8.0, 3000.0, 8.0>
74 vector gVAFT=<0.10, 0.10, 0.10>; //INITVAL=<0.10, 0.10, 0.10>
75 float gVADE=0.20; //INITVAL=0.20
76 float gVADT=0.50; //INITVAL=0.10
77 float gVAMT=1.0; //INITVAL=0.10
78 float gVAMDT=0.10; //INITVAL=0.10
79 float gVLDE=1.0; //INITVAL=1.0
80 float gVLDT=0.10; //INITVAL=0.10
81 float gVVAE=0.50; //INITVAL=0.50
82 float gVVAT=5.0; //INITVAL=5.0
83 float gVHE=0.0; //INITVAL=0.0
84 float gVHT=0.0; //INITVAL=0.0
85 float gVHH=0.0; //INITVAL=0.0
86 float gVB=0.0; //INITVAL=0.0
87 float gVBE=1.0; //INITVAL=1.0
88 float gVBM=0.5; //INITVAL=0.5
89 float gVBT=0.5; //INITVAL=0.5
90 float gVerticalThrust=7.0;
91 //---------------------------------------------------------------------
92
93 //---iTEC POWERTRAIN + (e3s) GLOBAL VARIABLES -------------------------
94 integer gGear;
95 integer gNewGear;
96 float gGearPower;
97 float gReversePower = -15;
98 list gGearPowerList = [ 2, // STAGER
99 15, // BURNOUT
100 20, // 1ST
101 40, // 2ND
102 70, // 3RD
103 80, // 4TH
104 100, // 5TH
105 110, // 6TH
106 155, // PRO-STOCK (START-DRAG-CLASS)
107 170, // PRO-MOD
108 198, // TOP-FUEL
109 256 // OPEN-PRO
110 ];
111 //integer gGearCount;
112 string gPhysEngDesc;
113 integer gPhysEng=1; // if os function is off set this to 0=ODE| 1=Bullet
114 float gTurnMulti=1.012345;
115 float gTurnRatio;
116 list gTurnRatioList;
117 string gGearName;
118 list gGearNameList =[ "STAGER",
119 "BURNOUT",
120 "1ST-GEAR",
121 "2ND-GEAR",
122 "3RD-GEAR",
123 "4TH-GEAR",
124 "5TH-GEAR",
125 "6TH-GEAR",
126 "PRO-STOCK",
127 "PRO-MOD",
128 "TOP-FUEL",
129 "OPEN-PRO"
130 ];
131 float gSpeed=0;
132 //---------------------------------------------------------------------
133
134 //---------------------------------------------------------------------
135 //NEED A KEYWORD PRIM ANIMATION PROCESSOR
136 integer gTurnCount;
137 string gTurnAngle = "NoTurn"; // LeftTurn or RightTurn or NoTurn
138 string gNewTurnAngle = "NoTurn";
139 string gTireSpin = "ForwardSpin"; // ForwardSpin or BackwardSpin or NoSpin
140 string gNewTireSpin = "ForwardSpin";
141 string gRotorSpin = "NoRotate"; // NoRotate or SlowRotate or FastRotate
142 integer gTcountL; //for cornerF
143 Xinteger gTcountR;
144
145 //---------------------------------------------------------------------
146
147 //---MENU HANDLER------------------------------------------------------
148 list MENU_MAIN = ["Align", "Hello"]; // up to 12 items in list
149 integer menu_handler;
150 integer menu_channel;
151 //---------------------------------------------------------------------
152
153 //=======================================================================
154 //==== 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 ====
155 //=======================================================================
156 init_TSvar(integer i){
157 if(i==0){
158 gTSvarList = [ 3.0, // how fast to reach max speed
159 0.10, // how fast to reach min speed or zero
160 <7.0,3000.0,100.0>, // XYZ linear friction
161 <0.10,0.10,0.20>, // XYZ angular friction
162 0.90, // how fast turning force is applied
163 0.50, // how fast turning force is released
164 1.0, // adjusted on 0.7.6
165 0.10,
166 0.20,
167 0.10,
168 0.50,
169 5.0,
170 0.0,
171 0.0,
172 0.0,
173 0.0
174 ];
175 }else{
176 gTSvarList = [
177 0.90, // 0
178 0.10, // 1
179 <1.0,1.0,1.0>, // 2
180 <1.0,1000.0,1000.0>, // 3
181 0.20, // 4
182 0.10, // 5
183 0.10, // 6
184 10.00, // 7
185 0.10, // 8
186 10.00, // 9
187 3.00, // 10
188 2.00, // 11
189 0.0, // 12
190 0.0, // 13
191 0.0, // 14
192 0.0, // 15
193 1.0, // 16
194 1.0, // 17
195 0.5 // 18
196 ];
197 }
198 gVLMT=llList2Float(gTSvarList,0);
199 gVLMDT=llList2Float(gTSvarList,1);
200 gVLFT=llList2Vector(gTSvarList,2);
201 gVAFT=llList2Vector(gTSvarList,3);
202 gVAMT=llList2Float(gTSvarList,4);
203 gVAMDT=llList2Float(gTSvarList,5);
204 gVLDE=llList2Float(gTSvarList,6);
205 gVLDT=llList2Float(gTSvarList,7);
206 gVADE=llList2Float(gTSvarList,8);
207 gVADT=llList2Float(gTSvarList,9);
208 gVVAE=llList2Float(gTSvarList,10);
209 gVVAT=llList2Float(gTSvarList,11);
210 gVHE=llList2Float(gTSvarList,12);
211 gVHT=llList2Float(gTSvarList,13);
212 gVHH=llList2Float(gTSvarList,14);
213 gVB=llList2Float(gTSvarList,15);
214 gVBE=llList2Float(gTSvarList,16);
215 gVBM=llList2Float(gTSvarList,17);
216 gVBT=llList2Float(gTSvarList,18);
217
218 }
219
220 init_PhysEng(){
221 string msg;
222
223 //gPhysEngDesc=osGetPhysicsEngineType();
224 //if(gPhysEngDesc=="OpenDynamicsEngine"){
225 // msg =":: is tuned for OpenDynamicsEngine";
226 // gPhysEng=0;
227 //}else if(gPhysEngDesc=="BulletSim"){
228 // msg =":: is tuned for BulletSim";
229 // gPhysEng=1;
230 //}else{
231 // msg ="WARNING:Automatic Detection of Physics Engine is off.";
232 //}
233
234 if(gPhysEng==0){
235 msg =":: is tuned for OpenDynamicsEngine";
236 }else if(gPhysEng==1){
237 msg =":: is tuned for BulletSim";
238 }
239
240 if(gPhysEng==0){
241 gTurnMulti=gTurnMulti;
242 init_TSvar(0);
243 gTurnRatioList = [ 2.4, // STAGER
244 2.4, // BURNOUT
245 2.4, // 1ST
246 2.5, // 2ND
247 4.5, // 3RD
248 5.0, // 4TH
249 5.5, // 5TH
250 6.5, // 6TH
251 7.5, // PRO-STOCK (START-DRAG-CLASS)
252 10.0, // PRO-MOD
253 10.0, // TOP-FUEL
254 10.0 // OPEN-PRO
255 ];
256 gGearPowerList = [ 2, // STAGER
257 10, // BURNOUT
258 15, // 1ST
259 50, // 2ND
260 70, // 3RD
261 85, // 4TH
262 100, // 5TH
263 110, // 6TH
264 155, // PRO-STOCK (START-DRAG-CLASS)
265 170, // PRO-MOD
266 200, // TOP-FUEL
267 256 // OPEN-PRO
268 ];
269
270
271 }else{
272 gTurnMulti=1.12345;
273 init_TSvar(1);
274 gTurnRatioList = [ 0.50, // STAGER
275 0.75, // BURNOUT
276 1.0, // 1ST
277 1.6, // 2ND
278 1.7, // 3RD
279 1.8, // 4TH
280 1.9, // 5TH
281 2.0, // 6TH
282 2.0, // PRO-STOCK (START-DRAG-CLASS)
283 2.0, // PRO-MOD
284 2.0, // TOP-FUEL
285 2.0 // OPEN-PRO
286 ];
287
288 gGearPowerList = [ 2, // STAGER
289 15, // BURNOUT
290 30, // 1ST
291 60, // 2ND
292 80, // 3RD
293 90, // 4TH
294 100, // 5TH
295 110, // 6TH
296 155, // PRO-STOCK (START-DRAG-CLASS)
297 170, // PRO-MOD
298 198, // TOP-FUEL
299 256 // OPEN-PRO
300 ];
301
302 }
303 llSay(0,msg);
304 }
305
306 preload_sounds(){
307 llPreloadSound(gSoundFlight);
308 llPreloadSound(gSoundHorn);
309 llPreloadSound(gSoundStartup);
310 llPreloadSound(gSoundIdle);
311 llPreloadSound(gSoundSlow);
312 llPreloadSound(gSoundAggressive);
313 llPreloadSound(gSoundGearUp);
314 llPreloadSound(gSoundGearDown);
315 llPreloadSound(gSoundRev);
316 llPreloadSound(gSoundAlarm);
317 }
318
319 init_engine(){
320 gRun = 0;
321 llSetSitText(gSitMessage);
322 llCollisionSound("", 0.0);
323 gSitTarget_Rot = llRot2Euler( llGetRootRotation() ); // SIT TARGET IS BASED ON VEHICLE'S ROTATION.
324 llSitTarget(gSitTarget_Pos, llEuler2Rot(DEG_TO_RAD * gSitTarget_Rot));
325 gOldSound=3;
326 gNewSound=3;
327 gTireSpin = "NoSpin";
328 gTurnAngle = "NoTurn";
329 gRotorSpin = "NoRotate";
330 llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
331 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY); // NO SPIN
332 llMessageLinked(LINK_SET, 0, gTurnAngle, NULL_KEY); // NO TURN
333 llMessageLinked(LINK_SET, 0, gRotorSpin, NULL_KEY); // SLOW SPIN
334 }
335
336 init_followCam(){
338 CAMERA_ACTIVE, 1, // 0=INACTIVE 1=ACTIVE
339 CAMERA_BEHINDNESS_ANGLE, 2.5, // (0 to 180) DEGREES
340 CAMERA_BEHINDNESS_LAG, 0.3, // (0 to 3) SECONDS
341 CAMERA_DISTANCE, 6.0, // ( 0.5 to 10) METERS
342 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 12.0, // (-45 to 80) DEGREES
343 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
344 CAMERA_POSITION_LAG, 0.0, // (0 to 3) SECONDS
345 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) METERS
346 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
347 CAMERA_FOCUS_LAG, 0.0, // (0 to 3) SECONDS
348 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) METERS
349 CAMERA_FOCUS_OFFSET, <0.0,0,0> // <-10,-10,-10> to <10,10,10> METERS
350 ]);
352 }
353
354 init_fixedCam(float degrees) {
355 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
356 llSetCameraEyeOffset(<-10, 0, 3.5> * sitRot);
357 llSetCameraAtOffset(<4, 0, 3> * sitRot);
359 }
360
361 set_engine(){
367 llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0.00000, 0.00000, 0.00000, 0.00000>);
368 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, gVLMT);
373 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, gVAMDT);
387
388 llRemoveVehicleFlags(vfW); // NOT FOR OPENSIM
389 llRemoveVehicleFlags(vfA); // NOT FOR OPENSIM
390 llSetVehicleFlags(vfG); // NOT FOR OPENSIM
391 gRotorSpin = "SlowRotate";
392 llMessageLinked(LINK_SET, 0, gRotorSpin, NULL_KEY); // SLOW SPIN
393 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
394 }
395
396 powershift(integer g){
397 if(!gMoving){
398 if(gCamFixed==0){
401 }
402 }
403 else {
404 vector vel = llGetVel();
405 float speed = llVecMag(vel);
406 if(speed <=20){
407 if(gCamFixed==0){
410 }
411 }
412 else if((speed >=21) || (speed <=50)){
413 if(gCamFixed==0){
416 }
417 }
418 else if(speed >=51) {
419 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 <=10){
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 <=10){
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 Ground;
503 }
504 }
505
506 state Ground{
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, <3,3,20>, ZERO_VECTOR, FALSE);
525 }
526 else {
528 llSetStatus(STATUS_ROTATE_Y,TRUE);
529 llSetStatus(STATUS_ROTATE_Z,TRUE);
530 gOldAgent = gAgent;
531 init_PhysEng();
532 set_engine();
534 gRun = 1;
535 }
536 }
537 else {
538 llSetStatus(STATUS_PHYSICS, FALSE); //SHOULD THIS BE THE LAST THING YOU SET??
539 gRun = 0;
540 //init_PhysEng();
541 init_engine();
542 llTriggerSound(gSoundStop,1);
543 llStopAnimation(gDrivingAnim);
544 llPushObject(gAgent, <3,3,20>, ZERO_VECTOR, FALSE);
545 llSetTimerEvent(0.0);
549 llSetCameraParams([CAMERA_ACTIVE, 0]);
550 llSetText("",<0,0,0>,1.0);
551 }
552 }
553 }
555 if(perm) {
556 gGear = 2; // GEAR#0 IS STAGER | GEAR#1 IS BURNOUT | GEAR#2 IS THE FIRST GEAR (LIST INDEX STARTS @ 0)
557 //gNewGear = 2;
559 if(gCamFixed == 1) {
560 init_fixedCam(0);
561 }else{
562 init_followCam();
563 }
564 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
565 llMessageLinked(LINK_SET, 0, "headlight", "0");
566 llStartAnimation(gDrivingAnim);
567 llTriggerSound(gSoundStartup,1.0);
568 llSleep(1.5);
569 enginesound();
570 }
571 }
572
573 control(key id, integer held, integer change){
574 if(gRun == 0){
575 return;
576 }
577 integer reverse=1;
578 vector vel = llGetVel();
579 vector speedvec = llGetVel() / llGetRot();
580 gSpeed = llVecMag(vel);
581 gTurnRatio = llList2Float(gTurnRatioList,gGear);
582
583 if((held & change & CONTROL_RIGHT) || ((gGear >= 11) && (held & CONTROL_RIGHT))){
584 gGear=gGear+1;
585 if(gGear < 0) gGear = 0;
586 if(gGear > 11) gGear = 11;
587 gearshift(gGear);
588 }
589
590 if((held & change & CONTROL_LEFT) || ((gGear >= 11) && (held & CONTROL_LEFT))){
591 gGear=gGear-1;
592 if(gGear < 0) gGear = 0;
593 if(gGear > 11) gGear = 11;
594 gearshift(gGear);
595
596 }
597
598 if(held & CONTROL_FWD){
599 if(gGear == 0) {
601 }else{
603 }
604 if(gGear == 1) {
605 llMessageLinked(LINK_SET, 0, "letsburn", NULL_KEY);
606 llMessageLinked(LINK_SET, 0, "letsscreech", NULL_KEY);
607 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
608 }
609 if(gGear == 2) {
610 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
611 }
612 if(gGear == 3) {
613 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
614 }
615 if(gGear == 4) {
616 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
617 }
618 if(gGear == 5) {
619 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
620 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
621 }
622 if(gGear == 6) {
623 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
624 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
625 }
626 if(gGear == 7) {
627 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
628 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
629 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
630 }
631 if(gGear == 8) {
632 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
633 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
634 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
635 }
636 if(gGear == 9) {
637 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
638 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
639 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
640 }
641 if(gGear == 10) {
642 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
643 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
644 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
645 }
646 if(gGear == 11) {
647 llMessageLinked(LINK_SET, 0, "pipeflame_steady", NULL_KEY);
648 llMessageLinked(LINK_SET, 0, "pipeflame_strong", NULL_KEY);
649 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
650 }
651 powershift(gGear);
653 gMoving=1;
654 reverse=1;
655 gNewTireSpin = "ForwardSpin";
656
657 }
658
659 if(held & CONTROL_BACK){
663 gTurnRatio = -2.0;
664 reverse = -1;
665 gNewTireSpin = "BackwardSpin";
666 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
667 }
668 if(~held & change & CONTROL_FWD){
669 //llSay(0,"CONTROL_FWD:Released");
670 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
671 gNewTireSpin = "NoSpin";
672 gNewTurnAngle = "NoTurn";
673 }
674 if(~held & change & CONTROL_BACK){
675 //llSay(0,"CONTROL_BACK:Released");
676 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
677 gNewTireSpin = "NoSpin";
678 gNewTurnAngle = "NoTurn";
679 }
680 if(~held & ~change & CONTROL_FWD){
681 //llSay(0,"CONTROL_FWD:Inactive");
682 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
683 }
684 if(~held & ~change & CONTROL_BACK){
685 //llSay(0,"CONTROL_BACK:Inactive");
686 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
687 }
688
689 showdata("Speed Vector:" + (string)speedvec + " Speed:" + (string)(gSpeed*2.23692912) + " mph");
690 enginesound();
691
692 vector AngularMotor;
693 AngularMotor.y=0;
694 if(held & (CONTROL_ROT_RIGHT)){
695 if(gGear<3){
696 AngularMotor.x += ((gTurnRatio/gTurnMulti)*1);
697 AngularMotor.z -= ((gTurnRatio*gTurnMulti)/1);
698 }else if(gGear==3){
699 AngularMotor.x += ((gTurnRatio/gTurnMulti)*1);
700 AngularMotor.z -= ((gTurnRatio*gTurnMulti)/2);
701 }else{
702 AngularMotor.x += ((gTurnRatio/gTurnMulti)*1);
703 AngularMotor.z -= ((gTurnRatio*gTurnMulti)/7);
704 }
705 gNewTurnAngle = "RightTurn";
706 gTurnCount = 10;
707 gTcountR = 2;
708 }
709
710 if(held & (CONTROL_ROT_LEFT)){
711 if(gGear<3){
712 AngularMotor.x -= ((gTurnRatio/gTurnMulti)*1);
713 AngularMotor.z += ((gTurnRatio*gTurnMulti)/1);
714 }else if(gGear==3){
715 AngularMotor.x -= ((gTurnRatio/gTurnMulti)*1);
716 AngularMotor.z += ((gTurnRatio/gTurnMulti)/2);
717 }else{
718 AngularMotor.x -= ((gTurnRatio/gTurnMulti)*1);
719 AngularMotor.z += ((gTurnRatio/gTurnMulti)/7);
720 }
721 gNewTurnAngle = "LeftTurn";
722 gTurnCount = 10;
723 gTcountL = 2;
724 }
725 if(held & CONTROL_UP) {
726 AngularMotor.y -= ((gTurnRatio*gTurnMulti)*1);
727 } else if(change & CONTROL_UP) {
728 AngularMotor.y = 0;
729 }
730
731 if(held & CONTROL_DOWN) {
732 AngularMotor.y += ((gTurnRatio*gTurnMulti)*1);
733 } else if(change & CONTROL_DOWN) {
734 AngularMotor.y = 0;
735 }
737 if(gTcountL > 0){
738 gTcountL--;
739 //llSay(0,(string)gTcountL);
740 }
741 if(gTcountL == 1){
742 cornerFXL();
743 }
744 if(gTcountR > 0){
745 gTcountR--;
746 // llSay(0,(string)gTcountR);
747 }
748 if(gTcountR == 1){
749 cornerFXR();
750 }
751
752 if(gTurnCount > 0){
753 gTurnCount--;
754 }
755 if(gTurnCount == 1){
756 gNewTurnAngle = "NoTurn";
757 }
758 if(gTurnAngle != gNewTurnAngle){
759 gTurnAngle = gNewTurnAngle;
761 }
762 if(gTireSpin != gNewTireSpin){
763 gTireSpin = gNewTireSpin;
765 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
766 }
767
768 }
769
770 touch_start(integer total_number){
771 if(gAgent != NULL_KEY){
772 menu(llDetectedKey(0), "\nDriver's Menu.", MENU_MAIN);
773 }
774 }
775
776 listen(integer channel,string name,key id,string message){
777 if(channel == menu_channel){
778 llListenRemove(menu_handler);
780 if(message == "Align"){
781 llSay(0, "Car is lined up...");
782 nearestpi();
783 }
784 else if(message == "Hello"){
785 llSay(0, "Hello yourself");
786 }
787 // else if(message == "Button"){
788 // do something
789 //}
790 }
791 }
792
793
794 link_message(integer sender, integer num, string str, key id){
795
796 integer i = llGetLinkNumber() != 0; // Start at zero (single prim) or 1 (two or more prims)
797 integer x = llGetNumberOfPrims() + i; // [0, 1) or [1, llGetNumberOfPrims()]
798
799 for (; i < x; ++i)
800 {
801
802 if(llGetLinkName(i) == "spin")
803 {
804 rotation rootRot = llGetRootRotation();
805 vector rootPos = llGetRootPosition();
806
807 list params = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL,PRIM_SIZE]);
808 rotation childRot = llList2Rot(params,1);
809 vector childPos = (llList2Vector(params,0)-rootPos)/rootRot;
810 vector childSize = llList2Vector(params,2);
811
812 if(str == "ForwardSpin"){
813 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, TWO_PI, 2.0]);
814 }else if(str == "BackwardSpin"){
815 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, -TWO_PI, 1.0]);
816 }else if(str == "NoSpin"){
817 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*childRot, 0, 1.0]);
818 }
819 }else if(llGetLinkName(i) == "spin_y"){
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, <0.0,90.0,0.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
824 }else if(str == "FastRotate"){
825 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
826 }
827 }else if(llGetLinkName(i) == "spin_x"){
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, <90.0,0.0,0.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
832 }else if(str == "FastRotate"){
833 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <90.0,0.0,0.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
834 }
835 }else if(llGetLinkName(i) == "spin_z"){
836 if(str == "NoRotate"){
837 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*0, 0, 0.987654]);
838 }else if(str == "SlowRotate"){
839 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,0.0,90.0>*DEG_TO_RAD*1, TWO_PI*2, 0.987654]);
840 }else if(str == "FastRotate"){
841 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,0.0,90.0>*DEG_TO_RAD*1, TWO_PI*4, 0.987654]);
842 }
843 }
844 }
845 }
846
847 timer(){
848 llListenRemove(menu_handler);
849 if(gRun == 1){
850
851 }else{
852 llSetTimerEvent(0.0);
853 }
854 }
855 }

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