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 Boat  

OpenSim Boat

Full-perm OpenSim boat with tunable parameters

Category: Vehicle
By : Sherrie Melody
Created: 2014-02-10 Edited: 2014-02-08
Worlds: Second Life

the Zip file

Download all files for OpenSim Boat
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1 // Gotten from MineThere Always.
2 // It came from a full-perm boat that is given away on Osgrid, on Wright Plaza.
3 // The original is a really great script, except it had a few things hard coded throughout the script.
4 // I modified it slightly to allow these things to be enabled/disabled and configured in variables toward the top of the script.
5 // See my comments at the top of the script. I've tested the modified script and it works nicely.
6
7 //############################ OpenSim - Physical Boat Script v2.2 ###############################
8
9 //Possibly authored by Nebadon from OsGrid, not sure. The boat the script originated in was
10 // originally given out on OsGrid, on Wright Plaza, full-perms, no limitations
11 //11/4/2013 Sherrie Melody modified slightly so that a couple of things are configurable, instead of hard-coded:
12 // 1. whether to play the motor sound. See instructions under GLOBAL VARIABLES FOR MOTOR SOUND
13 // 2. whether to enable particle-system jet spray prims, and if so, the names of those prims (4)
14 // See instructions under GLOBAL VARIABLES FOR THE JET SPRAY PRIMS
15 // 3. whether to enable monitor prim, and if so, the prim name
16 // See instructions under GLOBAL VARIABLES FOR MONITOR PRIM
17 //---------------------- Set Aktion-Range here (Simborder-crossing Protection) -------------------
18
19 integer EN = 1; // Switcher: EN = 1 (enables Protection), EN = 0 (disables Protection)
20 integer RX = 2; // how many Regions in X-Direction (West to East) default for single Region is 1
21 integer RY = 2; // how many Regions in Y-Direction (South to North) default for single Region is 1
22 integer VL =10; // Minimum Distance to a Simborder (is one length of the Vehicle in Meters)
23 float HH =21; // Hoverhigh of the Vehicle in Meters ( default is Waterhigh + 1 Meter)
24
25 //------------------------------------------------------------------------------------------------
26 // GLOBAL VARIABLES FOR MOTOR SOUND
27 integer SOUND_ENABLED = 0;//if set to one, plays sound named below
28 string MOTOR_SOUND = "Motor-05"; // motor sound (sm added variable for the name)
29
30 // GLOBAL VARIABLES FOR THE JET SPRAY PRIMS
31 // There are 4, front-left, front-right, back-left, back-right.
32 // In the original boat, these were placed toward the back of the boat, on the bottom, two at the back on either side
33 // of the boat, and two more about 2 meters forward of the back prims.
34 // The script rotates the two front prims so that their top faces forward.
35 // The script rotates the two rear prims so that their top faces backward.
36 // the HE_texture variable (further down) is used for the water spray texture.
37 integer JS_ENABLED = 0;//if 1, jetspray particle system enabled, 0 to disable
38 string JS_FR = "jet spray front-right";
39 string JS_FL = "jet spray front-left";
40 string JS_BR = "jet spray back-right";
41 string JS_BL = "jet spray back-left";
42 integer JS_FRL=0;//don't touch, set by script, link number for JS_FR
43 integer JS_FLL=0;//don't touch, set by script, link number for JS_FL
44 integer JS_BRL=0;//don't touch, set by script, link number for JS_BR
45 integer JS_BLL=0;//don't touch, set by script, link number for JS_BL
46
47 // GLOBAL VARIABLES FOR MONITOR PRIM
48 // There is a prim that receives link messages from the boat:
49 // "on-1" when the pilot sits
50 // "[speed value] Km/h" every 0.2 seconds after pilot sits
51 // "Standby" when the pilot gets up
52 // If you want to script a prim that does things in response to
53 // these messages, enable monitor and set the name of that prim below
54 integer MON_ENABLED = 0;// if one, script will send messages to prim named below
55 string MON_NAME = "monitor";//name of prim to receive link messages from this script
56 integer MON_NUM=0;//set by script, monitor link number
57
58 // GLOBAL VARIABLES FOR PILOT SEATING AND CAMERA VIEWPOINT
59 //
60 string PILOT_ANIM = "cartdriver3"; // current Sit-Animation (must be in Vehicle Content)
61 vector SIT_POSITION =<0.0, -2.7, 0.63> ; // position of pilot on sit prim
62 vector SIT_ROTATION = <0, 0, 90>; // rotation of pilot on sit prim
63 integer Private = 0; // 1= Owner Only Pilot. 0= Anyone can be Pilot.
64 float CAM_ZOOM = 12.0; // How far back the pilot's camera follows
65 float CAM_ANGLE = 12.0; // Vertical angle pilot's camera follows
66 float CZ;
67 //
68 // GLOBAL VARIABLES FOR TEXT & DIALOG
69 //
70 string sit_message = "Ride !";
71 string not_owner_message = "Sorry. You are not the owner.";
72 string TITLE="";
73 string StartUpText = " Use Arrows: Fwd/Rew, Left/Right, PageUp/Down";
74 //
75 // GLOBAL VARIABLES FOR VEHICLE MOTION
76 //
77 integer hps = 4; // Minimum horizontal Power-Rate
78 float hpm = 32; // Maximum horizontal Power-Rate
79 float hpr = 4; // Power change Factor
80 float hp;
81 float hp_old;
82 float vmin = 0.75; // minimum Hoverhigh over Water
83 float Curveangl = 7.5; // Angle of Vihicle at Curves
84 float angz = 0.5; // Sharpness of turns/curves (practical values 0.5 to 1.0)
85 float angz_low = 0.2;
86 float angz_high = 0.5;
87 //
88 // GLOBAL VARIABLES FOR PARTICLES
89 //
90 vector HE_start_color = <1.0, 1.0, 1.0>;
91 vector HE_end_color;
92 float HE_start_alpha = 1.0;
93 float HE_end_alpha;
94 vector HE_start_scale;
95 vector HE_end_scale;
96 string HE_texture = "Light Flare";
97 float HE_source_max_age = 0.0;
98 float HE_particle_max_age;
99 float HE_burst_rate = 0.0;
100 integer HE_burst_particle_count;
101 float HE_burst_radius = 0.25;
102 float HE_angle_begin = 0;
103 float HE_angle_end = 20 * DEG_TO_RAD;
104 float HE_speed_min;
105 float HE_speed_max;
106 //------------------------------------
107 integer H_dir = 1; // Indicator for Vihicle Horizontal moving Back = -1 or FWD = 1 or stop = 0
108 float HS;
109 integer HPC;
110 //
111 // GENEREL GLOBAL VARIABLES (DO NOT CHANGE !!!)
112 //
113 float ALTITUDE;
114 vector ANGULAR_MOTOR;
115 integer RUN;
116 key AVATAR;
117 float SPEED;
118 float OFFSET;
119 integer HELD;
120 integer P;
121 integer H_Gear;
122 float SB;
123 float HGfac = 2.0;
124 float PXY_S;
125 integer ME = 1;
126 integer dir; // Indicator for Vehicle Direction FWD/BACK used at XYrotation
127 float HF = DEG_TO_RAD * 90;
128 float HB = DEG_TO_RAD * 270;
129 float L2;
130
131 //----------------------------------- Subroutines ----------------------------------------
132 getJSprims() {
133 integer numPrims = llGetNumberOfPrims();
134 integer i;
135 for(i=1;i<=numPrims;i++) {
136 if(llGetLinkName(i) == JS_FR && JS_ENABLED == 1) {
137 JS_FRL = i;
138 }
139 else if(llGetLinkName(i) == JS_FL && JS_ENABLED == 1) {
140 JS_FLL = i;
141 }
142 else if(llGetLinkName(i) == JS_BR && JS_ENABLED == 1) {
143 JS_BRL = i;
144 }
145 else if(llGetLinkName(i) == JS_BL && JS_ENABLED == 1) {
146 JS_BLL = i;
147 }
148 else if(llGetLinkName(i) == MON_NAME && MON_ENABLED == 1) {
149 MON_NUM = i;
150 }
151 }
152 }
153
154
155 MOVE_ENABLE_FWD()
156 {
157 vector R_Pos = llGetPos(); vector R_Rot = llRot2Euler(llGetRot()); float AZ = R_Rot.z * RAD_TO_DEG;
158 float sin = llFabs(llSin(R_Rot.z)); float cos = llFabs(llCos(R_Rot.z));
159
160 float PXL = VL + PXY_S * sin; float PXH = RX * 256 - (VL + PXY_S * sin);
161 float PYL = VL + PXY_S * cos; float PYH = RY * 256 - (VL + PXY_S * cos);
162
163 if((AZ >= 0) && (AZ < 90))
164 {
165 if((R_Pos.x <= PXL) || (R_Pos.y >= PYH)) {ME = 0;}
166 }
167
168 if(AZ >= 90)
169 {
170 if((R_Pos.x <= PXL) || (R_Pos.y <= PYL)) {ME = 0;}
171 }
172
173 if((AZ < 0) && (AZ > -90))
174 {
175 if((R_Pos.x >= PXH) || (R_Pos.y >= PYH)) {ME = 0;}
176 }
177
178 if(AZ <= -90)
179 {
180 if((R_Pos.x >= PXH) || (R_Pos.y <= PYL)) {ME = 0;}
181 }
182
183 }
184
185
186 MOVE_ENABLE_REW()
187 {
188 vector R_Pos = llGetPos(); vector R_Rot = llRot2Euler(llGetRot()); float AZ = R_Rot.z * RAD_TO_DEG;
189 float sin = llFabs(llSin(R_Rot.z)); float cos = llFabs(llCos(R_Rot.z));
190
191 float PXL = VL + PXY_S * sin; float PXH = RX * 256 - (VL + PXY_S * sin);
192 float PYL = VL + PXY_S * cos; float PYH = RY * 256 - (VL + PXY_S * cos);
193
194 if((AZ >= 0) && (AZ < 90))
195 {
196 if((R_Pos.x >= PXH) || (R_Pos.y <= PYL)) {ME = 0;}
197 }
198
199 if(AZ >= 90)
200 {
201 if((R_Pos.x >= PXH) || (R_Pos.y >= PYH)) {ME = 0;}
202 }
203
204 if((AZ < 0) && (AZ > -90))
205 {
206 if((R_Pos.x <= PXL) || (R_Pos.y <= PYL)) {ME = 0;}
207 }
208
209 if(AZ <= -90)
210 {
211 if((R_Pos.x <= PXL) || (R_Pos.y >= PYH)) {ME = 0;}
212 }
213
214 }
215
216
217 SetParticle_HL()
218 {
219 llLinkParticleSystem(JS_BLL,[
220
221 //System Behaviour
227 ,
228
229 //System Presentation
231 PSYS_SRC_BURST_RADIUS, HE_burst_radius,
232 PSYS_SRC_ANGLE_BEGIN, HE_angle_begin,
233 PSYS_SRC_ANGLE_END, HE_angle_end,
234
235 //Particle appearance
236 PSYS_PART_START_COLOR, HE_start_color,
237 PSYS_PART_END_COLOR, HE_end_color,
238 PSYS_PART_START_ALPHA, HE_start_alpha,
239 PSYS_PART_END_ALPHA, HE_end_alpha,
240 PSYS_PART_START_SCALE, HE_start_scale,
241 PSYS_PART_END_SCALE, HE_end_scale,
242 PSYS_SRC_TEXTURE, HE_texture,
243
244 //Particle Flow
245 PSYS_SRC_MAX_AGE, HE_source_max_age,
246 PSYS_PART_MAX_AGE, HE_particle_max_age,
247 PSYS_SRC_BURST_RATE, HE_burst_rate,
248 PSYS_SRC_BURST_PART_COUNT, HE_burst_particle_count,
249
250 //Particle Motion
251 PSYS_SRC_BURST_SPEED_MIN, HE_speed_min,
252 PSYS_SRC_BURST_SPEED_MAX, HE_speed_max
253
254 ]);
255 }
256
257 SetParticle_HR()
258 {
259 llLinkParticleSystem(JS_BRL,[
260
261 //System Behaviour
267 ,
268
269 //System Presentation
271 PSYS_SRC_BURST_RADIUS, HE_burst_radius,
272 PSYS_SRC_ANGLE_BEGIN, HE_angle_begin,
273 PSYS_SRC_ANGLE_END, HE_angle_end,
274
275 //Particle appearance
276 PSYS_PART_START_COLOR, HE_start_color,
277 PSYS_PART_END_COLOR, HE_end_color,
278 PSYS_PART_START_ALPHA, HE_start_alpha,
279 PSYS_PART_END_ALPHA, HE_end_alpha,
280 PSYS_PART_START_SCALE, HE_start_scale,
281 PSYS_PART_END_SCALE, HE_end_scale,
282 PSYS_SRC_TEXTURE, HE_texture,
283
284 //Particle Flow
285 PSYS_SRC_MAX_AGE, HE_source_max_age,
286 PSYS_PART_MAX_AGE, HE_particle_max_age,
287 PSYS_SRC_BURST_RATE, HE_burst_rate,
288 PSYS_SRC_BURST_PART_COUNT, HE_burst_particle_count,
289
290 //Particle Motion
291 PSYS_SRC_BURST_SPEED_MIN, HE_speed_min,
292 PSYS_SRC_BURST_SPEED_MAX, HE_speed_max
293
294 ]);
295 }
296
297
298 SetParticle_HFL()
299 {
300 llLinkParticleSystem(JS_FLL,[
301
302 //System Behaviour
308 ,
309
310 //System Presentation
312 PSYS_SRC_BURST_RADIUS, HE_burst_radius,
313 PSYS_SRC_ANGLE_BEGIN, HE_angle_begin,
314 PSYS_SRC_ANGLE_END, HE_angle_end,
315
316 //Particle appearance
317 PSYS_PART_START_COLOR, HE_start_color,
318 PSYS_PART_END_COLOR, HE_end_color,
319 PSYS_PART_START_ALPHA, HE_start_alpha,
320 PSYS_PART_END_ALPHA, HE_end_alpha,
321 PSYS_PART_START_SCALE, HE_start_scale,
322 PSYS_PART_END_SCALE, HE_end_scale,
323 PSYS_SRC_TEXTURE, HE_texture,
324
325 //Particle Flow
326 PSYS_SRC_MAX_AGE, HE_source_max_age,
327 PSYS_PART_MAX_AGE, HE_particle_max_age,
328 PSYS_SRC_BURST_RATE, HE_burst_rate,
329 PSYS_SRC_BURST_PART_COUNT, HE_burst_particle_count,
330
331 //Particle Motion
332 PSYS_SRC_BURST_SPEED_MIN, HE_speed_min,
333 PSYS_SRC_BURST_SPEED_MAX, HE_speed_max
334
335 ]);
336 }
337
338
339 SetParticle_HFR()
340 {
341 llLinkParticleSystem(JS_FRL,[
342
343 //System Behaviour
349 ,
350
351 //System Presentation
353 PSYS_SRC_BURST_RADIUS, HE_burst_radius,
354 PSYS_SRC_ANGLE_BEGIN, HE_angle_begin,
355 PSYS_SRC_ANGLE_END, HE_angle_end,
356
357 //Particle appearance
358 PSYS_PART_START_COLOR, HE_start_color,
359 PSYS_PART_END_COLOR, HE_end_color,
360 PSYS_PART_START_ALPHA, HE_start_alpha,
361 PSYS_PART_END_ALPHA, HE_end_alpha,
362 PSYS_PART_START_SCALE, HE_start_scale,
363 PSYS_PART_END_SCALE, HE_end_scale,
364 PSYS_SRC_TEXTURE, HE_texture,
365
366 //Particle Flow
367 PSYS_SRC_MAX_AGE, HE_source_max_age,
368 PSYS_PART_MAX_AGE, HE_particle_max_age,
369 PSYS_SRC_BURST_RATE, HE_burst_rate,
370 PSYS_SRC_BURST_PART_COUNT, HE_burst_particle_count,
371
372 //Particle Motion
373 PSYS_SRC_BURST_SPEED_MIN, HE_speed_min,
374 PSYS_SRC_BURST_SPEED_MAX, HE_speed_max
375
376 ]);
377 }
378
379
380 SetPartVar_H0()
381 {
382 HE_end_color = <1.0,1.0,1.0>;
383 HE_end_alpha = 1.0;
384 HE_start_scale = <0.2, 0.2, 0.2>;
385 HE_end_scale = <0.3, 0.3, 0.3>;
386 HE_particle_max_age = 0.5;
387 HE_burst_particle_count = 1;
388 HE_speed_min = 0.0;
389 HE_speed_max = 0.2;
390 }
391
392
393 SetPartVar_H1()
394 {
395 HE_end_color = <1.0,1.0,1.0>;
396 HE_end_alpha = 0.0;
397 HE_start_scale = <0.0, 0.0, 0.0>;
398 HE_end_scale = <0.7, 0.7, 0.7>;
399 HE_particle_max_age = 1.0;
400 HE_burst_particle_count = 16 + HPC;
401 HE_speed_min = 0.5;
402 HE_speed_max = 0.5 + HS;
403 }
404
405
406 SETUP_CAMERA()
407 {
409 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
410 CAMERA_BEHINDNESS_ANGLE, 0, // (0 to 180) degrees
411 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
412 CAMERA_DISTANCE, CZ, // ( 1 to 30) meters
413 CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
414 CAMERA_FOCUS_LOCKED,FALSE, // (FALSE)
415 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
416 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, CAM_ANGLE, // (-45 to 80) degrees
417 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
418 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
419 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
420 CAMERA_FOCUS_OFFSET, <0.0, 0.0, 0.5> // <-10,-10,-10> to <10,10,10> meters
421 ]);
422 }
423
424
425 SETUP_VEHICLE()
426 {
427 // Vehicle Type
429
430 // Type Vector --------------------------------------------------------------
431
432 // friction
434 llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1.0, 1.0, 1.0>); // x,y in use
435 // motor
439
440 // Type Float -------------------------------------------------------
441
442 // hover
447 // friction
449 // motor
450 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.1); // in use
453 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 1.0); // in use
454 //deflection
459 // attraction
462 // banking
466 }
467
468 //------------------------------------ Default Programm -----------------------------------------
469
470 default
471 {
473 {
474 llSetStatus(STATUS_PHANTOM, FALSE);
478 llSetSitText(sit_message);
479 llSetText(TITLE, <0.5, 0.5, 1.0>, 1.0);
480 llSitTarget(SIT_POSITION,llEuler2Rot(DEG_TO_RAD * SIT_ROTATION));
481 }
482
483
484 on_rez(integer rn)
485 {
487 }
488
489
490 //----------------------------------- Changed Watcher ---------------------------------------------
491
492 changed(integer change)
493 {
494 if((change & CHANGED_LINK) == CHANGED_LINK)
495 {
496 getJSprims();//gets jet-spray prim numbers if JS_ENABLED, and monitor prim if MON_ENABLED
497 AVATAR = llAvatarOnSitTarget();
498 if(AVATAR != NULL_KEY)
499 {
500 if( (AVATAR != llGetOwner()) & (Private == 1))
501 {
502 llSay(0, not_owner_message);
503 llUnSit(AVATAR);
504 }
505 else
506 {
507 vector posv = llGetPos(); ALTITUDE = (posv.z - 20.00);
508 SETUP_VEHICLE(); llSleep(0.3);
509 llSetStatus(STATUS_PHANTOM, FALSE);
515
516 RUN = 1; OFFSET=0; L2 = llLog(2); hp = hps; H_Gear = 1;
517 PXY_S = HGfac * llPow(2, llLog(hps) / L2 - 2);
518 dir = 1; H_dir = 0; angz = angz_high; P = 1;
519 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
520 llStartAnimation(PILOT_ANIM);
521 llSay(0, StartUpText);
522 llSetText("", <0.5, 0.5, 1.0>, 1.0);
523 if(MON_ENABLED == 1) { llMessageLinked(MON_NUM, 0, "on-1", "");}
524 CZ = 4.0; SETUP_CAMERA(); llSleep(3.5); CZ = CAM_ZOOM; SETUP_CAMERA();
525 llSetTimerEvent(0.2);
526 if(JS_ENABLED == 1) {
527 llSetLinkPrimitiveParamsFast(JS_BLL, [PRIM_ROT_LOCAL, llEuler2Rot(<HB, 0, 0>)]); llSleep(0.1);
528 llSetLinkPrimitiveParamsFast(JS_BLL, [PRIM_ROT_LOCAL, llEuler2Rot(<HF, 0, 0>)]);
529 llSetLinkPrimitiveParamsFast(JS_BRL, [PRIM_ROT_LOCAL, llEuler2Rot(<HB, 0, 0>)]); llSleep(0.1);
530 llSetLinkPrimitiveParamsFast(JS_BRL, [PRIM_ROT_LOCAL, llEuler2Rot(<HF, 0, 0>)]);
531 llSetLinkPrimitiveParamsFast(JS_FLL, [PRIM_ROT_LOCAL, llEuler2Rot(<HF, 0, 0>)]); llSleep(0.1);
532 llSetLinkPrimitiveParamsFast(JS_FLL, [PRIM_ROT_LOCAL, llEuler2Rot(<HB, 0, 0>)]);
533 llSetLinkPrimitiveParamsFast(JS_FRL, [PRIM_ROT_LOCAL, llEuler2Rot(<HF, 0, 0>)]); llSleep(0.1);
534 llSetLinkPrimitiveParamsFast(JS_FRL, [PRIM_ROT_LOCAL, llEuler2Rot(<HB, 0, 0>)]);
535 SetPartVar_H0();
536 SetParticle_HL(); SetParticle_HR();
537 SetParticle_HFL(); SetParticle_HFR();
538 }
539 }
540 }
541 else
542 {
543 RUN = 0;
545 llStopAnimation(PILOT_ANIM);
546 if(MON_ENABLED == 1) {llMessageLinked(MON_NUM, 0, "Standby", "");}
547 llSetText(TITLE, <0.5, 0.5, 1.0>, 1.0);
551 vector pos = llGetPos(); llSetPos(<pos.x, pos.y, HH>);
553 if(JS_ENABLED==1) {
554 llLinkParticleSystem(JS_BLL,[]); llLinkParticleSystem(JS_BRL,[]);
555 llLinkParticleSystem(JS_FLL,[]); llLinkParticleSystem(JS_FRL,[]);
556 }
557 }
558 }
559 }
560
561 //------------------------------------- Runtime declaration --------------------------------
562
564 {
565 if(perm)
566 {
570 }
571 }
572
573
574 //---------------------------------------- Speed - metering -------------------------------------
575
576 timer()
577 {
578 if(RUN == 1)
579 {
580 SPEED = llVecMag(llGetVel());
581 string SpeedText = ((string)llRound(SPEED * 1.852) + " Km/h");
582 if(MON_ENABLED == 1) {llMessageLinked(MON_NUM, 0, SpeedText, "");}
583 }
584 }
585
586
587 //-------------------------------------- Keybord Control --------------------------------------------
588
589 control(key id, integer level, integer edge)
590 {
591 if(RUN == 0) {return;}
592
593 //------------------ Parking Mode on/off
594
595 if(level & CONTROL_RIGHT)
596 {
597 if(angz == angz_low)
598 {
599 angz = angz_high; hp = H_Gear * hpr; P = 0;
600 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
601 llWhisper(0, "Driving !");
602 }
603
604 if((angz == angz_high) && (P == 1))
605 {
606 angz = angz_low; hp = 4;
607 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
608 llWhisper(0, "Parking !");
609 }
610 P = 1;
611 }
612
613 //------------------- Speed change
614
615 if(level & CONTROL_UP)
616 {
617 H_Gear += 1; hp = H_Gear * hpr;
618 if(hp >= hpm) {hp = hpm; H_Gear = 8;}
619 PXY_S = HGfac * llPow(2, llLog(hp) / L2 - 2);
620 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
621 llWhisper(0, " Speed-Gear: " + (string)H_Gear );
622 }
623
624 if(level & CONTROL_DOWN)
625 {
626 H_Gear -= 1; hp = H_Gear * hpr;
627 if(hp < hps) {hp = hps; H_Gear = 1;}
628 PXY_S = HGfac * llPow(2, llLog(hp) / L2 - 2);
629 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
630 llWhisper(0, " Speed-Gear: " + (string)H_Gear );
631 }
632
633 //------------------ move Fwd/Back
634
635 if(level & CONTROL_FWD)
636 {
637 if(EN == 1) {MOVE_ENABLE_FWD();}
638
639 if(ME == 1)
640 {
641 H_dir = 1; dir = 1;
643 }
644 }
645
646 if(level & CONTROL_BACK)
647 {
648 if(EN == 1) {MOVE_ENABLE_REW();}
649
650 if(ME == 1)
651 {
652 H_dir = -1; dir = -1;
654 }
655 }
656
657 //------------------ turn Right/Left
658
659 if(level & CONTROL_ROT_RIGHT)
660 {
661 ANGULAR_MOTOR = <0, 0, -(angz + SPEED / (4 * hp))>;
662 OFFSET = Curveangl; HELD=1;
664 ANGULAR_MOTOR = <0, 0, 0>;
665 }
666
667 if(level & CONTROL_ROT_LEFT)
668 {
669 ANGULAR_MOTOR = <0, 0, (angz + SPEED / (4 * hp))>;
670 OFFSET = -Curveangl; HELD=1;
672 ANGULAR_MOTOR = <0, 0, 0>;
673 }
674
675 //--------------------------------------------------------------------------------------------------
676
677 if(HELD==0) {OFFSET=0;}
679 llSetRot(llEuler2Rot(<0, DEG_TO_RAD * OFFSET * dir, 0>)* llEuler2Rot(<0 ,0, rot.z>));
680
681 if(H_dir == 0)
682 {
683 if(OFFSET == 0 && JS_ENABLED==1)
684 {
685 SetPartVar_H0(); SetParticle_HL(); SetParticle_HR(); SetParticle_HFL(); SetParticle_HFR();
686 }
687
688 if(OFFSET < 0)
689 {
690 hp_old = hp; hp = hps;
691 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
692 if(JS_ENABLED==1) {
693 SetPartVar_H0(); SetParticle_HL(); SetParticle_HFR();
694 SetPartVar_H1(); SetParticle_HFL(); SetParticle_HR();
695 }
696 hp = hp_old;
697 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
698 }
699
700 if(OFFSET > 0)
701 {
702 hp_old = hp; hp = hps;
703 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
704 if(JS_ENABLED==1) {
705 SetPartVar_H1(); SetParticle_HL(); SetParticle_HFR();
706 SetPartVar_H0(); SetParticle_HFL(); SetParticle_HR();
707 }
708 hp = hp_old;
709 HS = llLog(hp) / L2 - 1; HPC = llRound(2 * llPow(2, HS));
710 }
711
712 }
713
714 if(H_dir == 1 && JS_ENABLED==1)
715 {
716 SetPartVar_H1(); SetParticle_HL(); SetParticle_HR();
717 SetPartVar_H0(); SetParticle_HFL(); SetParticle_HFR();
718 }
719
720 if(H_dir == -1 && JS_ENABLED==1)
721 {
722 SetPartVar_H0(); SetParticle_HL(); SetParticle_HR();
723 SetPartVar_H1(); SetParticle_HFL(); SetParticle_HFR();
724 }
725
726 if((H_dir != 0) || (OFFSET != 0)) { if(SOUND_ENABLED == 1) {llPlaySound(MOTOR_SOUND, 1.0); } }
727
728 dir = 1; HELD = 0; ME = 1; H_dir = 0;
729
730
731 } // End Keybord Control
732
733 }// End Default

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