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 Supercar  

Opensim BulletSim Supercar

The supercar

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

the Zip file

Download all files for Opensim BulletSim Supercar
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1
2 // Supercar has been tested for both ODE and Bulletsim and are both configured to go really fast. You just need to remember that if you do not have atleast a 20482048 varregion, you will have to refrain from using the the top 4 gears which was actually design for drag racing.
3
4 //*******************************************************
5 // Shin Ingen @ http://ingen-lab.com:8002
6 // LSL | OPENSIM | BulletSim and ODE | ACDC
7 // iTEC + e3s + DC (ENGINE SPEED SENSITIVE STEERING WITH DYNAMIC CAMERA)
8 // JANUARY 28, 2013
9 // TODO: KEYWORD PROCESSOR FOR ** PRIM ANIMATION | AVATAR ANIMATION | SOUNDS | MENU | HUD | DYNAMIC CAMERA
10 //*******************************************************
11
12 // Rev 1.1 04-14-2015 Vegaslon changed llSetVehicleRotationParam to reset all axes <0,0,0>
13 // Ferd commented out useless code that assigned a var to itself and other vars that are never used.
14
15 //---PERMISSION VARIABLES---------------------------------------------
16 integer gDrivePermit = 1; // 0=EVERYONE 1=OWNERONLY
17 string gSitMessage = "Drive";
18 string gUrNotAllowedMessage = "Vehicle is Locked";
19 vector gSitTarget_Pos = <-0.25,2.1,1.25>;
20 vector gSitTarget_Rot;
21 key gOldAgent;
22 key gAgent;
23 integer gRun; //ENGINE RUNNING
24 integer gMoving; //VEHICLE MOVING
25 //integer gIdle;
26 //---END PREMISSION----------------------------------------------------
27
28 //---ANIMATION VARIABLES-----------------------------------------------
29 string gDrivingAnim = "driverLH-64-64";
30 //---------------------------------------------------------------------
31
32 //---CAMERA VARIABLES--------------------------------------------------
33 //***CONSTANT**********************************************************
34 integer gCamFixed=0; // INITVAL=0 0=FOLLOW CAM 1=FIXED CAM
35 //integer gCamAct; // INITVAL=1 0=INACTIVE 1=ACTIVE
36 //integer gCamFocLocked; // INITVAL=FALSE (TRUE or FALSE)
37 //integer gCamPoslocked; // INITVAL=FALSE (TRUE or FALSE)
38 //***SLIDERS***********************************************************
39 //float gCamBAng; // INITVAL=2.0 (0 to 180) DEGREES
40 //float gCamBLag; // INITVAL=0.1 (0 to 3) SECONDS
41 //float gCamDist; // INITVAL=8.0 (0.5 to 10) METERS
42 //float gCamFocLag; // INITVAL=0.1 (0 to 3) SECONDS
43 //float gCamFocThresh; // INITVAL=0.5 (0 to 4) METERS
44 //float gCamPitch; // INITVAL=20.0 (-45 to 80) DEGREES
45 //float gCamPoslag; // INITVAL=0.1 (0 to 3) SECONDS
46 //float gCamPosthresh; // INITVAL=0.5 (0 to 4) METERS
47 //vector gCamFocOff; // INITVAL=<0.10,0,0> <-10,-10,-10> to <10,10,10> METERS
48 //----END CAMERA-------------------------------------------------------
49
50 //---SOUND VARIABLES---------------------------------------------------
51 string gSoundFlight = "s_flight";
52 string gSoundHorn = "s_horn";
53 string gSoundStartup = "s_startup";
54 string gSoundIdle = "s_idle";
55 string gSoundSlow = "s_slow";
56 string gSoundAggressive = "s_fast";
57 string gSoundGearUp = "s_gearup";
58 string gSoundGearDown = "s_geardown";
59 string gSoundRev = "s_rev";
60 string gSoundAlarm = "s_alarm";
61 string gSoundStop = "s_rev";
62 //NEED KEYWORD SOUND PROCESSOR
63 integer gOldSound=3; //variable for sound function
64 integer gNewSound=3;
65 //---------------------------------------------------------------------
66
67 //---iTEC - STOCK ENGINE GLOBAL VARIABLES------------------------------
68 list gTSvarList;
69 float gVLMT=0.90; //INITVAL=0.90
70 float gVLMDT=0.10; //INITVAL=0.10
71 vector gVLFT=<8.0, 3000.0, 8.0>; //INITVAL=<8.0, 3000.0, 8.0>
72 vector gVAFT=<0.10, 0.10, 0.10>; //INITVAL=<0.10, 0.10, 0.10>
73 float gVADE=0.20; //INITVAL=0.20
74 float gVADT=0.50; //INITVAL=0.10
75 float gVAMT=1.0; //INITVAL=0.10
76 float gVAMDT=0.10; //INITVAL=0.10
77 float gVLDE=1.0; //INITVAL=1.0
78 float gVLDT=0.10; //INITVAL=0.10
79 float gVVAE=0.50; //INITVAL=0.50
80 float gVVAT=5.0; //INITVAL=5.0
81 float gVHE=0.0; //INITVAL=0.0
82 float gVHT=0.0; //INITVAL=0.0
83 float gVHH=0.0; //INITVAL=0.0
84 float gVB=0.0; //INITVAL=0.0
85 //---------------------------------------------------------------------
86
87 //---iTEC POWERTRAIN + (e3s) GLOBAL VARIABLES -------------------------
88 integer gGear;
89 //integer gNewGear;
90 float gGearPower;
91 float gReversePower = -15;
92 list gGearPowerList = [ 2, // STAGER
93 15, // BURNOUT
94 20, // 1ST
95 40, // 2ND
96 70, // 3RD
97 80, // 4TH
98 100, // 5TH
99 110, // 6TH
100 155, // PRO-STOCK (START-DRAG-CLASS)
101 170, // PRO-MOD
102 198, // TOP-FUEL
103 256 // OPEN-PRO
104 ];
105 //integer gGearCount;
106 //string gPhysEngDesc;
107 integer gPhysEng=1; // if os function is off set this to 0=ODE| 1=Bullet
108 float gTurnMulti=1.012345;
109 float gTurnRatio;
110 list gTurnRatioList;
111 string gGearName;
112 list gGearNameList =[ "STAGER",
113 "BURNOUT",
114 "1ST-GEAR",
115 "2ND-GEAR",
116 "3RD-GEAR",
117 "4TH-GEAR",
118 "5TH-GEAR",
119 "6TH-GEAR",
120 "PRO-STOCK",
121 "PRO-MOD",
122 "TOP-FUEL",
123 "OPEN-PRO"
124 ];
125 float gSpeed=0;
126 //---------------------------------------------------------------------
127
128 //---------------------------------------------------------------------
129 //NEED A KEYWORD PRIM ANIMATION PROCESSOR
130 integer gTurnCount;
131 string gTurnAngle = "NoTurn"; // LeftTurn or RightTurn or NoTurn
132 string gNewTurnAngle = "NoTurn";
133 string gTireSpin = "ForwardSpin"; // ForwardSpin or BackwardSpin or NoSpin
134 string gNewTireSpin = "ForwardSpin";
135
136 integer gTcountL; //for cornerF
137 Xinteger gTcountR;
138
139 //---------------------------------------------------------------------
140
141 //---MENU HANDLER------------------------------------------------------
142 list MENU_MAIN = ["Align", "Hello"]; // up to 12 items in list
143 integer menu_handler;
144 integer menu_channel;
145 //---------------------------------------------------------------------
146
147 //=======================================================================
148 //==== 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 ====
149 //=======================================================================
150 init_TSvar(integer i){
151 if(i==0){
152 gTSvarList = [ 3.0, // how fast to reach max speed
153 0.10, // how fast to reach min speed or zero
154 <7.0,3000.0,100.0>, // XYZ linear friction
155 <0.10,0.10,0.20>, // XYZ angular friction
156 0.90, // how fast turning force is applied
157 0.50, // how fast turning force is released
158 1.0, // adjusted on 0.7.6
159 0.10,
160 0.20,
161 0.10,
162 0.50,
163 5.0,
164 0.0,
165 0.0,
166 0.0,
167 0.0
168 ];
169 }else{
170 gTSvarList = [ 1.0, // how fast to reach max speed
171 0.10, // how fast to reach min speed or zero
172 <8.0,3000.0,8.0>, // XYZ linear friction
173 <0.10,0.10,0.10>, // XYZ angular friction
174 0.20, // how fast turning force is applied
175 0.20, // how fast turning force is released
176 0.80, // adjusted on 0.8.0
177 0.10,
178 1.0,
179 0.10,
180 0.50,
181 5.0,
182 0.0,
183 0.0,
184 0.0,
185 0.0
186 ];
187 }
188 gVLMT=llList2Float(gTSvarList,0);
189 gVLMDT=llList2Float(gTSvarList,1);
190 gVLFT=llList2Vector(gTSvarList,2);
191 gVAFT=llList2Vector(gTSvarList,3);
192 gVAMT=llList2Float(gTSvarList,4);
193 gVAMDT=llList2Float(gTSvarList,5);
194 gVLDE=llList2Float(gTSvarList,6);
195 gVLDT=llList2Float(gTSvarList,7);
196 gVADE=llList2Float(gTSvarList,8);
197 gVADT=llList2Float(gTSvarList,9);
198 gVVAE=llList2Float(gTSvarList,10);
199 gVVAT=llList2Float(gTSvarList,11);
200 gVHE=llList2Float(gTSvarList,12);
201 gVHT=llList2Float(gTSvarList,13);
202 gVHH=llList2Float(gTSvarList,14);
203 gVB=llList2Float(gTSvarList,15);
204
205 }
206
207 init_PhysEng(){
208 string msg;
209 //gPhysEngDesc=osGetPhysicsEngineType();
210 //if(gPhysEngDesc=="OpenDynamicsEngine"){
211 // msg ="Your Vehicle is tuned for OpenDynamicsEngine";
212 // gPhysEng=0;
213 //}else if(gPhysEngDesc=="BulletSim"){
214 // msg ="Your Vehicle is tuned for BulletSim";
215 // gPhysEng=1;
216 //}else{
217 // msg ="WARNING:Automatic Detection of Physics Engine is off.";
218 //}
219 if(gPhysEng==0){
220 msg =":: is tuned for OpenDynamicsEngine";
221 }else if(gPhysEng==1){
222 msg =":: is tuned for BulletSim";
223 }
224
225 if(gPhysEng==0){
226 //gTurnMulti=gTurnMulti;
227 init_TSvar(0);
228 gTurnRatioList = [ 2.4, // STAGER
229 2.4, // BURNOUT
230 2.4, // 1ST
231 2.5, // 2ND
232 4.2, // 3RD
233 4.7, // 4TH
234 5.5, // 5TH
235 6.5, // 6TH
236 7.5, // PRO-STOCK (START-DRAG-CLASS)
237 10.0, // PRO-MOD
238 10.0, // TOP-FUEL
239 10.0 // OPEN-PRO
240 ];
241 gGearPowerList = [ 2, // STAGER
242 10, // BURNOUT
243 15, // 1ST
244 30, // 2ND
245 60, // 3RD
246 70, // 4TH
247 90, // 5TH
248 110, // 6TH
249 155, // PRO-STOCK (START-DRAG-CLASS)
250 170, // PRO-MOD
251 200, // TOP-FUEL
252 256 // OPEN-PRO
253 ];
254
255
256 }else{
257 gTurnMulti=0.987654;
258 init_TSvar(1);
259 gTurnRatioList = [ 1.3, // STAGER
260 1.5, // BURNOUT
261 1.5, // 1ST
262 2.5, // 2ND
263 3.9, // 3RD
264 4.0, // 4TH
265 4.1, // 5TH
266 4.5, // 6TH
267 10.0, // PRO-STOCK (START-DRAG-CLASS)
268 10.0, // PRO-MOD
269 10.0, // TOP-FUEL
270 10.0 // OPEN-PRO
271 ];
272
273 gGearPowerList = [ 2, // STAGER
274 15, // BURNOUT
275 20, // 1ST
276 40, // 2ND
277 70, // 3RD
278 80, // 4TH
279 100, // 5TH
280 110, // 6TH
281 155, // PRO-STOCK (START-DRAG-CLASS)
282 170, // PRO-MOD
283 198, // TOP-FUEL
284 256 // OPEN-PRO
285 ];
286
287 }
288 llSay(0,msg);
289 }
290
291 preload_sounds(){
292 llPreloadSound(gSoundFlight);
293 llPreloadSound(gSoundHorn);
294 llPreloadSound(gSoundStartup);
295 llPreloadSound(gSoundIdle);
296 llPreloadSound(gSoundSlow);
297 llPreloadSound(gSoundAggressive);
298 llPreloadSound(gSoundGearUp);
299 llPreloadSound(gSoundGearDown);
300 llPreloadSound(gSoundRev);
301 llPreloadSound(gSoundAlarm);
302 }
303
304 init_engine(){
305 gRun = 0;
306 llSetSitText(gSitMessage);
307 llCollisionSound("", 0.0);
308 gSitTarget_Rot = llRot2Euler( llGetRootRotation() ); // SIT TARGET IS BASED ON VEHICLE'S ROTATION.
309 llSitTarget(gSitTarget_Pos, llEuler2Rot(DEG_TO_RAD * gSitTarget_Rot));
310 gOldSound=3;
311 gNewSound=3;
312 gTireSpin = "NoSpin";
313 gTurnAngle = "NoTurn";
314 llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
315 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY); // NO SPIN
316 llMessageLinked(LINK_SET, 0, gTurnAngle, NULL_KEY); // NO TURN
317 }
318
319 init_followCam(float degrees){
321 CAMERA_ACTIVE, 1, // 0=INACTIVE 1=ACTIVE
322 CAMERA_BEHINDNESS_ANGLE, 4.0, // (0 to 180) DEGREES
323 CAMERA_BEHINDNESS_LAG, 0.02, // (0 to 3) SECONDS
324 CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) METERS
325 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 8.0, // (-45 to 80) DEGREES
326 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
327 CAMERA_POSITION_LAG, 0.000, // (0 to 3) SECONDS
328 CAMERA_POSITION_THRESHOLD, 8.0, // (0 to 4) METERS
329 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
330 CAMERA_FOCUS_LAG, 0.00 , // (0 to 3) SECONDS
331 CAMERA_FOCUS_THRESHOLD, 8.0, // (0 to 4) METERS
332 CAMERA_FOCUS_OFFSET, <0.10,0,0> // <-10,-10,-10> to <10,10,10> METERS
333 ]);
334 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
335 llSetCameraEyeOffset(<-10, 0, 3.5> * sitRot);
336 llSetCameraAtOffset(<4, 0, 3> * sitRot);
338 }
339
340 init_fixedCam(float degrees) {
341 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
342 llSetCameraEyeOffset(<-10, 0, 3.5> * sitRot);
343 llSetCameraAtOffset(<4, 0, 3> * sitRot);
345 }
346
347 set_engine(){
353 llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0.00000, 0.00000, 0.00000, 0.00000>); // rev 1.1 per Vegaslon's comment
354 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, gVLMT);
359 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, gVAMDT);
370
374 }
375
376 powershift(integer g){
377 if(!gMoving){
378 if(gCamFixed==0){
379 //enter your cam logic here
380 }
381 }
382 else {
383 vector vel = llGetVel();
384 float speed = llVecMag(vel);
385 if(speed <=20){
386 if(gCamFixed==0){
387 //enter your cam logic here
388 }
389 }
390 else if((speed >=21) || (speed <=50)){
391 if(gCamFixed==0){
392 //enter your cam logic here
393 }
394 }
395 else if(speed >=51) {
396 if(gCamFixed==0){
397 //enter your cam logic here
398 }
399
400 }
401 }
402 gGearPower = llList2Integer(gGearPowerList, g);
403 }
404
405 gearshift(integer g){
406 gGearName = llList2String(gGearNameList, g);
407 enginesound();
408 llSay(0,gGearName);
409 }
410
411 nearestpi(){
412 // ALIGNS THE VEHICLE EAST WEST SOUTH NORTH BASED ON CURRENT ROTATION (PRESTAGE AND STAGE DURING DRAG MODE)
414 llSetRot( llEuler2Rot( <Rad.x, Rad.y, llRound( Rad.z / PI_BY_TWO ) * PI_BY_TWO > ) );
415 }
416
417 menu(key user,string title,list buttons)
418 {
419 llListenRemove(menu_handler);
420 menu_channel = (integer)(llFrand(99999.0) * -1);
421 menu_handler = llListen(menu_channel,"","","");
422 llDialog(user,title,buttons,menu_channel);
423 llSetTimerEvent(30.0);
424 }
425
426 showdata(string s){
427 llSetText(s+"\n.\n.\n.\n.",<1,1,.6>,1.0);
428 //llSetText("",<0,0,0>,1.0);
429 }
430
431 enginesound(){
432 vector vel = llGetVel();
433 float speed = llVecMag(vel);
434 if(speed <=20){
435 gNewSound = 0;
436 }
437 else if(speed >=50){
438 gNewSound = 2;
439 }
440 else {
441 gNewSound = 1;
442 }
443
444 if(gOldSound != gNewSound){
445 if(speed <=20){
446 llLoopSound(gSoundIdle,1.0);
447 }
448 else if(speed >=50){
449 llLoopSound(gSoundAggressive,1.0);
450 }
451 else {
452 llLoopSound(gSoundSlow,1.0);
453 }
454 gOldSound = gNewSound;
455 }
456 }
457
458 cornerFXR(){
459 vector vel = llGetVel();
460 float speed = llVecMag(vel);
461 if(speed >50){
462 llMessageLinked(LINK_SET, 0, "letsburnR", NULL_KEY);
463 }
464 }
465
466 cornerFXL(){
467 vector vel = llGetVel();
468 float speed = llVecMag(vel);
469 if(speed >50){
470 llMessageLinked(LINK_SET, 0, "letsburnL", NULL_KEY);
471 }
472 }
473
474 default {
476 {
477 init_engine();
478 state Ground;
479 }
480 }
481
482 state Ground{
483
485 }
486 on_rez(integer param) {
488 preload_sounds();
489 init_PhysEng();
490 }
491
492 changed(integer change){
493 if((change & CHANGED_LINK) == CHANGED_LINK){
494 gAgent = llAvatarOnSitTarget();
495 if(gAgent != NULL_KEY){
496 if( (gAgent != llGetOwner()) && (gDrivePermit == 1)){
497 llSay(0, gUrNotAllowedMessage);
498 llUnSit(gAgent);
499 llPlaySound(gSoundAlarm,1.0);
500 llPushObject(gAgent, <0,0,20>, ZERO_VECTOR, FALSE);
501 }
502 else {
504 gOldAgent = gAgent;
505 init_PhysEng();
506 set_engine();
508 gRun = 1;
509 }
510 }
511 else {
512 llSetStatus(STATUS_PHYSICS, FALSE); //SHOULD THIS BE THE LAST THING YOU SET??
513 gRun = 0;
514 init_engine();
515 llTriggerSound(gSoundStop,1);
516 llStopAnimation(gDrivingAnim);
517 llSetTimerEvent(0.0);
521 llSetText("",<0,0,0>,1.0);
522 }
523 }
524 }
526 if(perm) {
527 gGear = 2; // GEAR#0 IS STAGER | GEAR#1 IS BURNOUT | GEAR#2 IS THE FIRST GEAR (LIST INDEX STARTS @ 0)
528 //gNewGear = 2;
530 if(gCamFixed == 1) {
531 init_fixedCam(0);
532 }else{
533 init_followCam(0);
534 }
535 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
536 llMessageLinked(LINK_SET, 0, "headlight", "0");
537 llStartAnimation(gDrivingAnim);
538 llTriggerSound(gSoundStartup,1.0);
539 llSleep(1.5);
540 enginesound();
541 }
542 }
543
544 control(key id, integer held, integer change){
545 if(gRun == 0){
546 return;
547 }
548 integer reverse=1;
549 vector vel = llGetVel();
550 vector speedvec = llGetVel() / llGetRot();
551 gSpeed = llVecMag(vel);
552 gTurnRatio = llList2Float(gTurnRatioList,gGear);
553
554 if((held & change & CONTROL_UP) || ((gGear >= 11) && (held & CONTROL_UP))){
555 gGear=gGear+1;
556 if(gGear < 0) gGear = 0;
557 if(gGear > 11) gGear = 11;
558 gearshift(gGear);
559 }
560
561 if((held & change & CONTROL_DOWN) || ((gGear >= 11) && (held & CONTROL_DOWN))){
562 gGear=gGear-1;
563 if(gGear < 0) gGear = 0;
564 if(gGear > 11) gGear = 11;
565 gearshift(gGear);
566 }
567 if(held & CONTROL_FWD){
568 if(gGear == 0) {
570 }else{
572 }
573 if(gGear == 1) {
574 llMessageLinked(LINK_SET, 0, "letsburn", NULL_KEY);
575 llMessageLinked(LINK_SET, 0, "letsscreech", NULL_KEY);
576 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
577 }
578 if(gGear == 2) {
579 }
580 if(gGear == 3) {
581 }
582 if(gGear == 4) {
583 }
584 if(gGear == 5) {
585 }
586 if(gGear == 6) {
587 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
588 }
589 if(gGear == 7) {
590 }
591 if(gGear == 8) {
592 }
593 if(gGear == 9) {
594 }
595 if(gGear == 10) {
596 }
597 if(gGear == 11) {
598 }
599 powershift(gGear);
601 gMoving=1;
602 reverse=1;
603 gNewTireSpin = "ForwardSpin";
604
605 }
606
607 if(held & CONTROL_BACK){
611 gTurnRatio = -2.0;
612 reverse = -1;
613 gNewTireSpin = "BackwardSpin";
614 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
615 }
616 if(~held & change & CONTROL_FWD){
617 //llSay(0,"CONTROL_FWD:Released");
618 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
619 gNewTireSpin = "NoSpin";
620 gNewTurnAngle = "NoTurn";
621
622 if(gGear > 9){
623 gGear = 3;
624 }
625
626 }
627 if(~held & change & CONTROL_BACK){
628 //llSay(0,"CONTROL_BACK:Released");
629 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
630 gNewTireSpin = "NoSpin";
631 gNewTurnAngle = "NoTurn";
632 }
633 if(~held & ~change & CONTROL_FWD){
634 //llSay(0,"CONTROL_FWD:Inactive");
635 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
636 }
637 if(~held & ~change & CONTROL_BACK){
638 //llSay(0,"CONTROL_BACK:Inactive");
639 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
640 }
641
642 showdata("Speed Vector:" + (string)speedvec + " Speed:" + (string)(gSpeed*2.23692912) + " mph");
643 enginesound();
644
645 vector AngularMotor;
647 if(gGear==0){
648 AngularMotor.z -= gSpeed / ((gTurnRatio/gTurnMulti)*1);
649 }else{
650 AngularMotor.z -= gSpeed / ((gTurnRatio/gTurnMulti)*gGear);
651 }
652 gNewTurnAngle = "RightTurn";
653 gTurnCount = 10;
654 gTcountR = 2;
655 }
656
658 if(gGear==0){
659 AngularMotor.z += gSpeed / ((gTurnRatio/gTurnMulti)*1);
660 }else{
661 AngularMotor.z += gSpeed / ((gTurnRatio/gTurnMulti)*gGear);
662 }
663 gNewTurnAngle = "LeftTurn";
664 gTurnCount = 10;
665 gTcountL = 2;
666 }
667
669 if(gTcountL > 0){
670 gTcountL--;
671 //llSay(0,(string)gTcountL);
672 }
673 if(gTcountL == 1){
674 cornerFXL();
675 }
676 if(gTcountR > 0){
677 gTcountR--;
678 // llSay(0,(string)gTcountR);
679 }
680 if(gTcountR == 1){
681 cornerFXR();
682 }
683
684 if(gTurnCount > 0){
685 gTurnCount--;
686 }
687 if(gTurnCount == 1){
688 gNewTurnAngle = "NoTurn";
689 }
690 if(gTurnAngle != gNewTurnAngle){
691 gTurnAngle = gNewTurnAngle;
693 }
694 if(gTireSpin != gNewTireSpin){
695 gTireSpin = gNewTireSpin;
697 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
698 }
699
700 }
701
702 touch_start(integer total_number){
703 if(gAgent != NULL_KEY){
704 menu(llDetectedKey(0), "\nDriver's Menu.", MENU_MAIN);
705 }
706 }
707
708 listen(integer channel,string name,key id,string message){
709 if(channel == menu_channel){
710 llListenRemove(menu_handler);
712 if(message == "Align"){
713 llSay(0, "Car is lined up...");
714 nearestpi();
715 }
716 else if(message == "Hello"){
717 llSay(0, "Hello yourself");
718 }
719 // else if(message == "Button"){
720 // do something
721 //}
722 }
723 }
724
725
726 link_message(integer sender, integer num, string str, key id){
727
728 integer i = llGetLinkNumber() != 0; // Start at zero (single prim) or 1 (two or more prims)
729 integer x = llGetNumberOfPrims() + i; // [0, 1) or [1, llGetNumberOfPrims()]
730
731 for (; i < x; ++i)
732 {
733
734 if(llGetLinkName(i) == "spin")
735 {
736 rotation rootRot = llGetRootRotation();
737 vector rootPos = llGetRootPosition();
738
739 list params = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL,PRIM_SIZE]);
740 rotation childRot = llList2Rot(params,1);
741 vector childPos = (llList2Vector(params,0)-rootPos)/rootRot;
742 vector childSize = llList2Vector(params,2);
743
744 if(str == "ForwardSpin"){
745 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, TWO_PI, 1.0]);
746 }else if(str == "BackwardSpin"){
747 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, -TWO_PI, 1.0]);
748 }else if(str == "NoSpin"){
749 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*childRot, 0, 1.0]);
750 }
751 }
752 }
753 }
754
755 timer(){
756 llListenRemove(menu_handler);
757 if(gRun == 1){
758
759 }else{
760 llSetTimerEvent(0.0);
761 }
762 }
763 }

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