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
Flight Assist Xflight_Script_1  

Xflight_Script_1

X-flight Script 1.lsl

Category: Flight Assist
By : Goodwill Epoch
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Xflight_Script_1
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Xflight_Script_1_1.lsl
1
2 //X-flight script for increased flying speed and control
3 //Developed by Goodwill Epoch on 6/12/2003
4 //Revision 1.9a
5 //For explicit use only by members of the Kazenojin Airship guild
6 //
7 //May be sold with explicit permission from Goodwill Epoch to non-members
8 //Settings must be set to no-modify no view to prevent theft of script
9 //script may not be modified without permission from Goodwill Epoch
10
11 //List of customizable commands
12 list commands = ["X", "go", "stop", "status", "speed", "accel", "pos", "accelmode", "turnmode", "hovermode", "posmode"];
13
14 //Help for commands
15 list com_help = ["Trigger for any commands to be entered", "Enable flight enhancements", "Disable flight enhancements", "List current modes and their state", "Current impulse, place a number after to set. limit 1-500", "Current acceleration, place a number after to set. limit 10-100", "Current coordinates", "Acceleration of movement. Use 'on' or 'off' to set.", "Slow down while turning. Use 'on' or 'off' to set.", "Allows hovering at all heights. Use 'on' or 'off' to set.", "Displays position over object. Use 'on' or 'off' to set."];
16
17 //Default movement variables
18 float speed = 200;
19 float accel = 25;
20 float move = 0;
21 float attached = 0;
22
23 //Counters and temp variables
24 float accel_count = 0;
25 string temp_newcommand;
26 integer temp_newcom_pos;
27 integer wait_for_conf = FALSE;
28 integer test_move = FALSE;
29
30 //Simplified say strings
31 string off = "off";
32 string on = "on";
33
34 //Default settings
35 integer accelmode = TRUE;
36 integer turnmode = TRUE;
37 integer hovermode = TRUE;
38 integer posmode = FALSE;
39
40 //Other variables
41 integer listen_num;
42 string notecard = "X-Flight enhanced flight info";
43 string notehelp = "X-Flight enhanced flight help";
44
45 //Returns a on/off string from a true/false pass
46 string on_off(integer test)
47 {
48 if(test)
49 {
50 return on;
51 }
52 else
53 {
54 return off;
55 }
56 }
57
58 //Returns a true/fals from an on/off string
59 integer true_false(string test)
60 {
61 if(test == on)
62 {
63 return TRUE;
64 }
65 else
66 {
67 return FALSE;
68 }
69 }
70
71 //Help menu handler
72 help()
73 {
74 llSay(0, "Current help");
75 integer a;
76 for(a = 0; a < llGetListLength(com_help); a++)
77 {
78 llSay(0, llList2String(commands, a) + " - " + llList2String(com_help, a));
79 }
80 llSay(0, "customize - Allows you to customize certain commands. '" + llList2String(commands, 0) + " customize [old command] [new command]' Be sure to use full words without spaces for commands. You will then need to type 'yes' to confirm.");
81 llSay(0, "reset - Resets entire script. '" + llList2String(commands, 0) + " reset' WARNING: Will erase all customize data and settings.");
82 }
83
84 //Allows customization of function names
85 customize(string old_com, string new_com)
86 {
87 //Checks for commands and proper commands
88 if((old_com == "") || (new_com == ""))
89 {
90 llSay(0, "Not enough information, please try again or view help for more info.");
91 }
92 else
93 {
94 integer listpos = llListFindList(commands, [old_com]);
95 if(listpos == -1)
96 {
97 llSay(0, "Command not found, please view help for more info on current command settings");
98 }
99 else //Sets up wait to confirm changing commands
100 {
101 temp_newcommand = new_com;
102 temp_newcom_pos = listpos;
103 llSay(0, "Do you want command '" + old_com + "' to be changed to '" + new_com + "'? Please say 'yes'");
104 wait_for_conf = TRUE;
105 }
106 }
107 }
108
109 //Take controls
110 get_controls()
111 {
112 llListenRemove(listen_num);
113 listen_num = llListen(0, "", llGetOwner(), "");
115 llSetText("", <0,0,0>, 0);
117 }
118
119 //Handle Commands
120 com_handle(integer com_num, string message)
121 {
122 if(com_num == 1) //Go
123 {
124 get_controls();
125 }
126 else if(com_num == 2) //Stop
127 {
129 llSay(0, "All stop");
130 }
131 else if(com_num == 3) //Status
132 {
133 llSay(0, "Current settings:");
134 llSay(0, llList2String(commands, 4) + " - " + (string)((integer)speed));
135 llSay(0, llList2String(commands, 5) + " - " + (string)((integer)accel));
136 llSay(0, llList2String(commands, 7) + " - " + on_off(accelmode));
137 llSay(0, llList2String(commands, 8) + " - " + on_off(turnmode));
138 llSay(0, llList2String(commands, 9) + " - " + on_off(hovermode));
139 llSay(0, llList2String(commands, 10) + " - " + on_off(posmode));
140 }
141 else if(com_num == 4) //Speed
142 {
143 float tempvar = (integer)message;
144 if((tempvar > 0) && (tempvar <= 500))
145 {
146 speed = tempvar;
147 llSay(0, llList2String(commands, com_num) + " is now " + (string)((integer)speed));
148 }
149 else
150 {
151 llSay(0, llList2String(commands, com_num) + " is currently " + (string)((integer)speed));
152 }
153 }
154 else if(com_num == 5) //Acceleration
155 {
156 float tempvar = (integer)message;
157 if((tempvar >= 10) && (tempvar <= 100))
158 {
159 accel = tempvar;
160 llSay(0, llList2String(commands, com_num) + " is now " + (string)((integer)accel));
161 }
162 else
163 {
164 llSay(0, llList2String(commands, com_num) + " is currently " + (string)((integer)accel));
165 }
166 }
167 else if(com_num == 6) //current pos
168 {
169 vector pos = llGetPos();
170 llSay(0, "<" + (string)((integer)pos.x) + ", " + (string)((integer)pos.y) + ", " + (string)((integer)pos.z) + ">");
171 }
172 else if(com_num == 7) //Acceleration mode
173 {
174 if((message == "off") || (message == "on"))
175 {
176 accelmode = true_false(message);
177 llSay(0, llList2String(commands, com_num) + " is now " + message);
178 }
179 else
180 {
181 llSay(0, llList2String(commands, com_num) + " is currently " + on_off(accelmode));
182 }
183 }
184 else if(com_num == 8) //Turning mode
185 {
186 if((message == "off") || (message == "on"))
187 {
188 turnmode = true_false(message);
189 llSay(0, llList2String(commands, com_num) + " is now " + message);
190 }
191 else
192 {
193 llSay(0, llList2String(commands, com_num) + " is currently " + on_off(turnmode));
194 }
195 }
196 else if(com_num == 9) //Hover Mode
197 {
198 if((message == "off") || (message == "on"))
199 {
200 hovermode = true_false(message);
201 llSay(0, llList2String(commands, com_num) + " is now " + message);
202 }
203 else
204 {
205 llSay(0, llList2String(commands, com_num) + " is currently " + on_off(hovermode));
206 }
207
208 }
209 else if(com_num == 10) //Position display mode
210 {
211 if((message == "off") || (message == "on"))
212 {
213 posmode = true_false(message);
214 llSay(0, llList2String(commands, com_num) + " is now " + message);
215 }
216 else
217 {
218 llSay(0, llList2String(commands, com_num) + " is currently " + on_off(posmode));
219 }
220 }
221 }
222
223 //Check for flight and altitude for hover
224 set_flight()
225 {
226 vector pos = llGetPos();
227 float ground = llGround(<0,0,0>);
229 {
230 move = 1;
231 if(hovermode && ((pos.z > 55) && (pos.z > (ground + 35))))
232 {
233 llSetForce(<0,0,9.8> * llGetMass(), FALSE);
234 }
235 else
236 {
237 llSetForce(<0,0,0>, FALSE);
238 }
239 }
240 else
241 {
242 move = 0;
243 llSetForce(<0,0,0>, FALSE);
244 }
245 // Display position over object if position mode is on
246 if(posmode)
247 {
248 llSetText("<" + (string)((integer)pos.x) + ", " + (string)((integer)pos.y) + ", " + (string)((integer)pos.z) + "> \n \n \n", <1,1,1>, 1);
249 }
250 else
251 {
252 llSetText("", <0,0,0>, 0);
253 }
254 }
255
256 //Handle Listen Messages
257 listen_handler(string message)
258 {
259 list lst_msg = llParseString2List(message, [" "],[]);
260 if(llList2String(lst_msg, 0) == llList2String(commands, 0))
261 {
262 wait_for_conf = FALSE;
263 if(llList2String(lst_msg, 1) == "help") //If help pass to help
264 {
265 help();
266 }
267 //If customize pass to customize
268 else if(llList2String(lst_msg, 1) == "customize")
269 {
270 customize(llList2String(lst_msg, 2), llList2String(lst_msg, 3));
271 }
272 //If reset reset script
273 else if(llList2String(lst_msg, 1) == "reset")
274 {
275 llSay(0, "Reseting Script");
277 }
278 //Pass to command handler if a command
279 else
280 {
281 integer listpos = llListFindList(commands, llList2List(lst_msg, 1, 1));
282 if(listpos != -1)
283 {
284 com_handle(listpos, llList2String(lst_msg, 2));
285 }
286 }
287 }
288 //If Response to customize, confirm
289 else if((llList2String(lst_msg, 0) == "yes") && wait_for_conf)
290 {
291 llSay(0, "Changing command to " + temp_newcommand);
292 commands = llDeleteSubList(commands, temp_newcom_pos, temp_newcom_pos);
293 commands = llListInsertList(commands, [temp_newcommand], temp_newcom_pos);
294 }
295 else
296 {
297 wait_for_conf = FALSE;
298 }
299 }
300
301 control_handler(integer levels, integer edges)
302 {
303 test_move =TRUE;
304 accel_count ++;
305 if(accel_count > accel)
306 {
307 accel_count = accel;
308 }
309 float acc_percent = 1;
310 if(accelmode)
311 {
312 accel_count ++;
313 if(accel_count > accel)
314 {
315 accel_count = accel;
316 }
317 acc_percent = accel_count / accel;
318 }
319 float turning = 1;
320 vector impulse = <0,0,0>;
321 if(levels & CONTROL_UP)
322 {
323 impulse += <0,0,speed>;
324 }
325 if(levels & CONTROL_DOWN)
326 {
327 impulse += <0,0,-speed>;
328 }
329 if(levels & CONTROL_FWD)
330 {
331 impulse += <speed,0,0>;
332 }
333 if(levels & CONTROL_BACK)
334 {
335 impulse += <-speed,0,0>;
336 }
337 if(levels & CONTROL_LEFT)
338 {
339 impulse += <0,speed,0>;
340 }
341 if(levels & CONTROL_RIGHT)
342 {
343 impulse += <0,-speed,0>;
344 }
345 if(levels & CONTROL_ROT_RIGHT)
346 {
347 if(turnmode)
348 {
349 turning = 0;
350 }
351 }
352 if(levels & CONTROL_ROT_LEFT)
353 {
354 if(turnmode)
355 {
356 turning = 0;
357 }
358 }
359 llApplyImpulse((vector)(impulse * move * turning * acc_percent), TRUE);
360 }
361
362 //Default State, sets up basic listens, and events
363 default
364 {
366 {
367 get_controls();
368 }
369
370 on_rez(integer param)
371 {
372 get_controls();
373 }
374
375 listen(integer channel, string name, key id, string message)
376 {
377 listen_handler(message);
378 }
379
380 control(key id, integer levels, integer edges)
381 {
382 control_handler(levels, edges);
383 }
384
385 timer()
386 {
387 set_flight();
388 if(!test_move)
389 {
390 accel_count = -1;
391 }
392 test_move = FALSE;
393 }
394
395 //Detect touch, if not owner then give info. If owner display help.
396 touch(integer total_touched)
397 {
398 integer a = 0;
399 key toucher;
400 for(a = 0; a < total_touched; a++)
401 {
402 toucher = llDetectedKey(a);
403 if(toucher == llGetOwner())
404 {
405 llGiveInventory(toucher, notehelp);
406 llSay(0, "Please type '" + llList2String(commands, 0) + " help' for more help with commands");
407 }
408 else
409 {
410 llGiveInventory(toucher, notecard);
411 }
412 }
413 }
414
415 //Detect if permission to take controls is enabled
416 run_time_permissions(integer permissions)
417 {
419 {
420 llSay(0, "All Go");
422 }
423 }
424 }
425
426 // END //

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