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 Flying_Saucer_Script_2  

Flying_Saucer_Script_2

Flying Saucer Script 2.lsl

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

the Zip file

Download all files for Flying_Saucer_Script_2
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Flying_Saucer_Script_2_1.lsl
1
2 float LINEAR_TAU = 0.75;
3 float TARGET_INCREMENT = 0.5;
4 float ANGULAR_TAU = 1.5;
5 float ANGULAR_DAMPING = 0.85;
6 float THETA_INCREMENT = 10;// 0.3
7 integer LEVELS = 0;
8 vector pos;
9 vector face;
10 float brake = 0.5;
11 key gOwnerKey;
12 string gOwnerName;
13 key gToucher;
14 key Driver;
15 string Name1 = "Mark Coffee";
16 string Name2 = "Mom's Paintings";
17 string gFLYING = "FALSE";
18 string sound="hum.wav";
19 key id;
20 integer nudge = FALSE;
21 vector POSITION;
22 integer auto=FALSE;
23 integer CHANNEL = 6;
24
25 help()
26 {
27 llWhisper(0,"Commands:");
28 llWhisper(0,"Left click craft = Start ");
29 llWhisper(0,"Left click craft = Stop and release contol");
30 llWhisper(0,"/" + (string)CHANNEL + " 1! through" + " /" + (string)CHANNEL + " 9!," + " /" + (string)CHANNEL + " slow or" + " /" + (string)CHANNEL + " warp = Set power");
31 llWhisper(0,"/" + (string)CHANNEL + " ask! = Craft asks permission for your control. (Only when outside craft)");
32 llWhisper(0,"/" + (string)CHANNEL + " menu = Display this list");
33 llWhisper(0,"PgUp or PgDn = Gain or lose altitude");
34 llWhisper(0,"Arrow keys = Left, right, Forwards and Back");
35 llWhisper(0,"Shift + Left or Right arrow = Rotate but maintain view");
36 llWhisper(0,"PgUp + PgDn or combination similar = Set cruise on or off");
37 }
38
39 default
40 {
42 {
43
44 gOwnerKey = llGetOwner();
45 gOwnerName = llKey2Name(llGetOwner());
46 llSoundPreload(sound);
48 llLoopSoundMaster(sound, 0.0);
49 llSetTimerEvent(0.0);
50 llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", id);
52 llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, TRUE);
53 llSleep(0.1);
54 llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
57 llRotLookAt(llGetRot(), 0, 0);
60
61 TARGET_INCREMENT = 0.5;
62 llSitTarget(<0.4, 0.0, 0.4>, ZERO_ROTATION);
63 llSetCameraEyeOffset(<-10.0, 0.0, 4.0>);
64 llSetSitText("Pilot");
65 llSetCameraAtOffset(<0, 0.0, 0>);
66 llWhisper(0,"Deactivated ... Security conditions set. Type /" + (string)CHANNEL + " menu for a list of options.");
67
68 // this sets a Listen with no callback in this state...
69 llListen(CHANNEL, "", "", "");
70
71 state Listening;
72 }
73
74 }
75
76 state Listening
77 {
78 // Here we set up the Listen that is used in the Listening state...
80 {
81 llListen(CHANNEL, "", "", "");
82 }
83
84 // the rest was here before...
85 // This is the click callback
86 touch_start(integer total_number)
87 {
88 if(llSameGroup(llDetectedKey(total_number - 1))==1 || llDetectedName(total_number - 1)==Name1 || llDetectedName(total_number - 1)==Name2)
89 {
90 if(gFLYING == "FALSE")
91 {
92 gFLYING = "TRUE";
94 llLoopSoundMaster(sound, 95.0);
96 llSetSitText("Ride");
97 Driver=llDetectedKey(total_number - 1);
98 state StateDriving;
99 }
100 }
101 else
102 {
103 llWhisper(0,"You must own or belong to this group to fly craft.");
105 llLoopSoundMaster(sound,0.0);
106 llInstantMessage(gOwnerKey,llDetectedName(total_number - 1) + " is touching your craft");
107 }
108 }
109
110 // Here is the Listen callback
111 listen(integer CHANNEL, string name, key id, string msg)
112 {
113 if(llSameGroup(id)==1)
114 {
115 if(llToLower(msg) == "menu")
116 {
117 help();
118 }
119 }
120 }
121
122 // and this is an on-rez callback
123 on_rez(integer start_param)
124 {
126 }
127 }
128
129 state StateDriving
130 {
132 {
133 llWhisper(0, "All systems go !!");
135 llMoveToTarget(llGetPos(), LINEAR_TAU);
136 llRotLookAt(llGetRot(), ANGULAR_TAU, 1.0);
137
138 // Added listen here as well.... for same reason...
139 llListen(CHANNEL, "", "", "");
140 }
141
142 touch_start(integer total_number)
143 {
144 if(llDetectedKey(total_number - 1)==Driver)
145 {
146 llWhisper(0,"You now have control.");
147 gFLYING = "FALSE";
148 auto=FALSE;
149 llSleep(1.5);
151 llLoopSoundMaster(sound, 0.0);
152 llSetSitText("Pilot");
154 llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", id);
155 llSetTimerEvent(0.0);
158 }
159 }
160
161 listen(integer CHANNEL, string name, key id, string msg)
162 {
163 if(id==Driver)
164 {
165 if(llToLower(msg) == "ask!")
166 {
169 }
170 if(llToLower(msg) == "menu")
171 {
172 help();
173 }
174 if(llToLower(msg) == "warp")
175 {
176 TARGET_INCREMENT = 10.0;
177 string TIspew = (string)TARGET_INCREMENT;
178 TIspew = llGetSubString(TIspew,0,3);
179 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
180 }
181 if(llToLower(msg) == "slow")
182 {
183 TARGET_INCREMENT = 0.5;
184 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
185 }
186 if(llToLower(msg) == "1!")
187 {
188 TARGET_INCREMENT = 0.75;
189 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
190 }
191 if(llToLower(msg) == "2!")
192 {
193 TARGET_INCREMENT = 1.0;
194 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
195 }
196 if(llToLower(msg) == "3!")
197 {
198 TARGET_INCREMENT = 1.5;
199 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
200 }
201 if(llToLower(msg) == "4!")
202 {
203 TARGET_INCREMENT = 2.0;
204 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
205 }
206 if(llToLower(msg) == "5!")
207 {
208 TARGET_INCREMENT = 3.0;
209 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
210 }
211 if(llToLower(msg) == "6!")
212 {
213 TARGET_INCREMENT = 4.0;
214 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
215 }
216 if(llToLower(msg) == "7!")
217 {
218 TARGET_INCREMENT = 5.0;
219 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
220 }
221 if(llToLower(msg) == "8!")
222 {
223 TARGET_INCREMENT = 6.0;
224 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
225 }
226 if(llToLower(msg) == "9!")
227 {
228 TARGET_INCREMENT = 7.0;
229 llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%");
230 }
231 }
232 }
233
235 {
237 {
238 llMessageLinked(LINK_ALL_CHILDREN, 0, "slow", id);
239 llTakeControls(LEVELS, TRUE, FALSE);
240
241 }
242 else
243 {
244 llWhisper(0,"Stopped");
245 llSetTimerEvent(0.0);
246 gFLYING = "FALSE";
247 llSleep(1.5);
249 }
250 }
251 control(key driver, integer levels, integer edges)
252 {
253 pos *= brake;
254 face.x *= brake;
255 face.z *= brake;
256 nudge = FALSE;
257 llMessageLinked(LINK_ALL_CHILDREN, 0, "slow", id);
258 if(levels & CONTROL_FWD)
259 {
260 if(pos.x < 0) { pos.x=0; }
261 else { pos.x += TARGET_INCREMENT; }
262 nudge = TRUE;
263 }
264 if(levels & CONTROL_BACK)
265 {
266 if(pos.x > 0) { pos.x=0; }
267 else { pos.x -= TARGET_INCREMENT; }
268 nudge = TRUE;
269 }
270 if(levels & CONTROL_UP)
271 {
272 llMessageLinked(LINK_ALL_CHILDREN, 0, "fast", id);
273 if(pos.z<0) { pos.z=0; }
274 else { pos.z += TARGET_INCREMENT; }
275 face.x=0;
276 nudge = TRUE;
277 }
278 if(levels & CONTROL_DOWN)
279 {
280 llMessageLinked(LINK_ALL_CHILDREN, 0, "fast", id);
281 if(pos.z>0) { pos.z=0; }
282 else { pos.z -= TARGET_INCREMENT; }
283 face.x=0;
284 nudge = TRUE;
285 }
286 if((levels) & (CONTROL_LEFT|CONTROL_ROT_LEFT))
287 {
288 if(face.z < 0) { face.z=0; }
289 else { face.z += THETA_INCREMENT; }
290 nudge = TRUE;
291 }
293 {
294 if(face.z > 0) { face.z=0; }
295 else { face.z -= THETA_INCREMENT; }
296 nudge = TRUE;
297 }
298 if((levels & CONTROL_UP) && (levels & CONTROL_DOWN))
299 {
300 if(auto)
301 {
302 auto=FALSE;
303 llWhisper(0,"Cruise off");
304 llSetTimerEvent(0.0);
305 }
306 else
307 {
308 auto=TRUE;
309 llWhisper(0,"Cruise on");
310 llSetTimerEvent(0.5);
311 }
312 llSleep(0.5);
313 }
314
315 if(nudge)
316 {
317 vector world_target = pos * llGetRot();
318 llMoveToTarget(llGetPos() + world_target, LINEAR_TAU);
319
320 vector eul = face;
321 eul *= DEG_TO_RAD;
322 rotation quat = llEuler2Rot( eul );
323 rotation rot = quat * llGetRot();
324 llRotLookAt(rot, ANGULAR_TAU, ANGULAR_DAMPING);
325 }
326 }
327
328 timer()
329 {
330 pos *= brake;
331 if(pos.x < 0) { pos.x=0; }
332 else { pos.x += TARGET_INCREMENT; }
333 vector world_target = pos * llGetRot();
334 llMoveToTarget(llGetPos() + world_target, LINEAR_TAU);
335 }
336
337 }
338 // END //

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