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
Vehicles XC51_hovercraft_script  

XC51_hovercraft_script

XC5-1 hovercraft pose ball controller

Category: Vehicles
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for XC51_hovercraft_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. XC51_hovercraft_script_1.lsl
Get file # 2. XC51_hovercraft_script_2.lsl
1
2
3 vector TARGET = <0,0,0.5>;
4 vector ROT = <0, 0,0>;
5
6
7
8 string seater;
9 key av;
10
11 DEBUG(string msg)
12 {
13 if(debug) llOwnerSay(llGetScriptName() + " :" + msg);
14 }
15
16
17
18 integer debug =0 ;
19
20 default
21 {
23 {
24
25 rotation rot = llEuler2Rot(ROT * DEG_TO_RAD); // convert the degrees to radians, then convert that vector into a rotation, rot30x
26 llSitTarget(TARGET, rot); // where they sit
27 }
28
29
30
31
32 changed(integer change)
33 {
34 if(change & CHANGED_LINK)
35 {
37
38 if(av) //evaluated as true if not NULL_KEY or invalid
39 {
41 }
42 else
43 {
45 DEBUG("unsit");
46 }
47
48 }
49
50
51 }
52
54 {
56 {
57 llStopAnimation("sit");
58 llStartAnimation("sit"); // replace this with your own animation
59
60 llMessageLinked(LINK_SET,0,"pilot",av);
61 DEBUG("sit");
62 // llSleep(4);
63 }
64 }
65
66
68 {
70 }
71 }

XC51_hovercraft_script

flight script for XC-5 hovercraft

Category: Vehicles
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1
2
3 key pilot;
4 vector pos;
5 vector linear;
6 vector angular;
7 integer under_power;
8 integer listenindex;
9 float throttle;
10 integer cloaked;
11
12 default
13 {
15 {
17 llWhisper(0, "Mode: Hover");
18 linear = ZERO_VECTOR;
19 angular = ZERO_VECTOR;
20 under_power = FALSE;
21 throttle = 0.0;
22 llMessageLinked(LINK_SET, (integer)throttle, "throttle", NULL_KEY);
23
24 llCollisionSound("", 0.0);
25 llSetCameraEyeOffset(<-10.0, 0.0, 3.0>);
26 llSetCameraAtOffset(<0.0, 0.0, 2.5>);
27
29
30 // linear friction
32
33 // uniform angular friction
35
36 // linear motor
38 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
40
41 // angular motor
44 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 2.0);
45
46 // hover
51
52 // linear deflection
55
56 // angular deflection
59
60 // vertical attractor
63
64 // banking
68
69 // default rotation of local frame
71
72 // removed vehicle flags
74
75 // set vehicle flags
77
78 llListenRemove(listenindex);
79 if(pilot != NULL_KEY) {
80 listenindex = llListen(0, "", pilot, "");
81 } else {
83 }
84
85 llSetTimerEvent(0.05);
86 }
87
88 on_rez(integer sparam)
89 {
91 }
92
93 link_message(integer sender, integer num, string str, key id)
94 {
95 if(str == "pilot" && id != NULL_KEY) {
96 linear = ZERO_VECTOR;
97 angular = ZERO_VECTOR;
98 under_power = FALSE;
99 throttle = 0.0;
101 pilot = id;
102 llListenRemove(listenindex);
103 listenindex = llListen(0, "", pilot, "");
104 } else if(str == "pilot" && id == NULL_KEY) {
106 if(cloaked) {
107 cloaked = FALSE;
108 llMessageLinked(LINK_SET, 0, "decloak", NULL_KEY);
109 }
110 llListenRemove(listenindex);
111 pilot = NULL_KEY;
113 }
114 }
115
116 run_time_permissions(integer permissions)
117 {
118 if(permissions & PERMISSION_TAKE_CONTROLS) {
128 TRUE, FALSE);
129 vector current_pos = llGetPos();
131 pos = current_pos;
133 }
134 }
135
136 control(key name, integer levels, integer edges)
137 {
138 if((edges & levels & CONTROL_UP)) {
140 linear.z += 12.0;
141 } else if((edges & ~levels & CONTROL_UP)) {
142 linear.z -= 12.0;
143 }
144 if((edges & levels & CONTROL_DOWN)) {
146 linear.z -= 12.0;
147 } else if((edges & ~levels & CONTROL_DOWN)) {
148 linear.z += 12.0;
149 }
150
151 if((edges & levels & CONTROL_FWD)) {
153 linear.x += 14.0;
154 } else if((edges & ~levels & CONTROL_FWD)) {
155 linear.x -= 14.0;
156 }
157 if((edges & levels & CONTROL_BACK)) {
159 linear.x -= 14.0;
160 } else if((edges & ~levels & CONTROL_BACK)) {
161 linear.x += 14.0;
162 }
163
164 if((edges & levels & CONTROL_LEFT)) {
166 linear.y += 8.0;
167 } else if((edges & ~levels & CONTROL_LEFT)) {
168 linear.y -= 8.0;
169 }
170 if((edges & levels & CONTROL_RIGHT)) {
172 linear.y -= 8.0;
173 } else if((edges & ~levels & CONTROL_RIGHT)) {
174 linear.y += 8.0;
175 }
176
177 if((edges & levels & CONTROL_ROT_LEFT)) {
179 angular.z += (PI / 180) * 55.0;
180 angular.x -= PI * 4;
181 } else if((edges & ~levels & CONTROL_ROT_LEFT)) {
182 angular.z -= (PI / 180) * 55.0;
183 angular.x += PI * 4;
184 }
185 if((edges & levels & CONTROL_ROT_RIGHT)) {
187 angular.z -= (PI / 180) * 55.0;
188 angular.x += PI * 4;
189 } else if((edges & ~levels & CONTROL_ROT_RIGHT)) {
190 angular.z += (PI / 180) * 55.0;
191 angular.x -= PI * 4;
192 }
193 }
194
195 timer()
196 {
198
200 }
201
202 listen(integer channel, string name, key id, string message)
203 {
204 message = llToLower(message);
205 if(message == "f" || message == "flight") {
206 state flight;
207 }
208 if(message == "decloak" || message == "d") {
209 if(cloaked) {
210 cloaked = FALSE;
211 llTriggerSound("cloak", 1.0);
212 llMessageLinked(LINK_SET, 0, "decloak", NULL_KEY);
213 } else {
214 llWhisper(0, "Cloak Currently Inactive");
215 }
216 }
217 if(message == "cloak" || message == "c") {
218 if(!cloaked) {
219 cloaked = TRUE;
220 llTriggerSound("cloak", 1.0);
221 llMessageLinked(LINK_SET, 0, "cloak", NULL_KEY);
222 } else {
223 llWhisper(0, "Cloak Already Active");
224 }
225 }
226 }
227 }
228
229 state flight
230 {
232 {
233 llMessageLinked(LINK_SET, 0, "flight", NULL_KEY);
234 llWhisper(0, "Mode: Flight");
235 linear = ZERO_VECTOR;
236 angular = ZERO_VECTOR;
237 throttle = 0.0;
238 under_power = FALSE;
239
240 llCollisionSound("", 0.0);
241 llSetCameraEyeOffset(<-12.0, 0.0, 3.0>);
242 llSetCameraAtOffset(<0.0, 0.0, 2.5>);
243
244 llListenRemove(listenindex);
245 if(pilot != NULL_KEY) {
246 listenindex = llListen(0, "", pilot, "");
247 }
248
250
251 // linear friction
253
254 // uniform angular friction
256
257 // linear motor
259 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.5);
261
262 // angular motor
265 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.2);
266
267 // hover
272
273 // linear deflection
276
277 // angular deflection
280
281 // vertical attractor
284
285 // banking
289
290 // default rotation of local frame
292
293 // removed vehicle flags
295
296 // set vehicle flags
298
299 llSetTimerEvent(0.05);
300 }
301
302 on_rez(integer sparam)
303 {
305 }
306
307 control(key name, integer levels, integer edges)
308 {
309 if((edges & levels & CONTROL_UP)) {
311 linear.z += 10.0;
312 } else if((edges & ~levels & CONTROL_UP)) {
313 linear.z -= 10.0;
314 }
315 if((edges & levels & CONTROL_DOWN)) {
317 linear.z -= 10.0;
318 } else if((edges & ~levels & CONTROL_DOWN)) {
319 linear.z += 10.0;
320 }
321
322 if((edges & levels & CONTROL_FWD)) {
324 angular.y += (PI / 180.0) * 45.0;
325 } else if((edges & ~levels & CONTROL_FWD)) {
326 angular.y -= (PI / 180.0) * 45.0;
327 }
328 if((edges & levels & CONTROL_BACK)) {
330 angular.y -= (PI / 180.0) * 75.0;
331 } else if((edges & ~levels & CONTROL_BACK)) {
332 angular.y += (PI / 180.0) * 75.0;
333 }
334
335 if((edges & levels & CONTROL_LEFT)) {
337 angular.x -= (PI / 180.0) * 120.0;
338 } else if((edges & ~levels & CONTROL_LEFT)) {
339 angular.x += (PI / 180.0) * 120.0;
340 }
341 if((edges & levels & CONTROL_RIGHT)) {
343 angular.x += (PI / 180.0) * 120.0;
344 } else if((edges & ~levels & CONTROL_RIGHT)) {
345 angular.x -= (PI / 180.0) * 120.0;
346 }
347
348 if((edges & levels & CONTROL_ROT_LEFT)) {
350 angular.x -= (PI / 180.0) * 120.0;
351 } else if((edges & ~levels & CONTROL_ROT_LEFT)) {
352 angular.x += (PI / 180.0) * 120.0;
353 }
354 if((edges & levels & CONTROL_ROT_RIGHT)) {
356 angular.x += (PI / 180.0) * 120.0;
357 } else if((edges & ~levels & CONTROL_ROT_RIGHT)) {
358 angular.x -= (PI / 180.0) * 120.0;
359 }
360 }
361
362 link_message(integer sender, integer num, string str, key id)
363 {
364 if(str == "pilot" && id != NULL_KEY) {
366 pilot = id;
367 llListenRemove(listenindex);
368 listenindex = llListen(0, "", pilot, "");
369 } else if(str == "pilot" && id == NULL_KEY) {
371 if(cloaked) {
372 cloaked = FALSE;
373 llMessageLinked(LINK_SET, 0, "decloak", NULL_KEY);
374 }
375 llListenRemove(listenindex);
376 pilot = NULL_KEY;
378 state default;
379 }
380 }
381
382 listen(integer channel, string name, key id, string message)
383 {
384 message = llToLower(message);
385
386 if(message == "h" || message == "hover" || message == "vtol") {
387 state default;
388 }
389 if(message == "r" || message == "i" || message == "reverse" || message == "invert thrust") {
390 throttle = -5.0;
391 }
392 if(message == "decloak" || message == "d") {
393 if(cloaked) {
394 cloaked = FALSE;
395 llTriggerSound("cloak", 1.0);
396 llMessageLinked(LINK_SET, 0, "decloak", NULL_KEY);
397 } else {
398 llWhisper(0, "Cloak Currently Inactive");
399 }
400 }
401 if(message == "cloak" || message == "c") {
402 if(!cloaked) {
403 cloaked = TRUE;
404 llTriggerSound("cloak", 1.0);
405 llMessageLinked(LINK_SET, 0, "cloak", NULL_KEY);
406 } else {
407 llWhisper(0, "Cloak Already Active");
408 }
409 }
410 }
411
412 timer()
413 {
414 if(linear.z > 0 && llGetTime() >= 0.25 && throttle < 100.0) {
415 if(throttle < 0.0) {
416 throttle = 0.0;
417 } else {
418 throttle += linear.z;
419 }
421 llMessageLinked(LINK_SET, (integer)throttle, "throttle", NULL_KEY);
422 } else if(linear.z < 0 && llGetTime() >= 0.25 && throttle > 0.0) {
423 throttle += linear.z;
425 llMessageLinked(LINK_SET, (integer)throttle, "throttle", NULL_KEY);
426 }
427
428 linear.x = 30.0 * (throttle / 100.0);
429 vector linear_applied = <linear.x, 0.0, 0.0>;
431
432 if(angular == ZERO_VECTOR) {
434 } else {
436 }
437
439 }
440 }// END //

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