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 flight_script  

flight_script

flight script.lsl

Category: Flight Assist
By : Barney Boomslang
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for flight_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. flight_script_1.lsl
1
2 // (c) 2006 Barney Boomslang
3 integer listener = 0;
4 integer speed = 0;
5 integer buoyancy = 0;
6
7 // up/down factor
8 float bfactor = 4;
9 float bfactor2 = 2;
10
11 list speeds = ["low", "medium", "high"];
12
13 init()
14 {
16 speed = 0;
25 llSetBuoyancy(0.0);
26 buoyancy = 0;
27 llListenRemove(listener);
28 listener = llListen(0, "", llGetOwner(), "");
29 llSetTimerEvent(1.0);
30 llSay(0, "Ready for boarding");
31 }
32
33 set_speed(string direction)
34 {
35 if(direction != "")
36 {
37 if(speed > 0)
38 {
39 llOwnerSay("Changing "+direction+" to "+llList2String(speeds, (speed - 1))+" speed");
40 }
41 else if(speed < 0)
42 {
43 llOwnerSay("engaging reverse gear");
44 }
45 else
46 {
47 llOwnerSay("Stopping engines");
48 }
49 }
50 if(buoyancy>=0)
51 {
52 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,speed*5,buoyancy*bfactor>);
53 }
54 else
55 {
56 llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,speed*5,buoyancy*bfactor2>);
57 }
59 }
60
61 default
62 {
63
64 changed(integer change)
65 {
66 key agent;
67 if(change & CHANGED_LINK)
68 {
69 llSleep(0.5);
70 agent = llAvatarOnSitTarget();
71 if(agent == llGetOwner())
72 {
73 llSay(0, "Say 'start' to start flying. Say 'stop' if you want to stop flying.");
74 }
75 else if(agent == NULL_KEY)
76 {
78 }
79 else
80 {
81 llSay(0, "Sorry, but the pilot has to be seated first!");
82 llUnSit(agent);
83 }
84 }
85 }
86
88 {
89 init();
90 }
91
92 on_rez(integer param)
93 {
94 init();
95 }
96
97 timer()
98 {
99 set_speed("");
100 }
101
102 listen(integer channel, string name, key agent, string message)
103 {
104 if(message == "stop")
105 {
107 buoyancy = 0;
109 llSay(0, "Airship fastened, it is now safe to stand up.");
110 }
111 else if(message == "start")
112 {
115 buoyancy = 0;
116 llSay(0, "Airship released, use the left/right to turn, fwd/back to set the speed and up/down to change the height.");
117 }
118 }
119
121 {
123 {
125 }
126 }
127
128 control(key id, integer held, integer change)
129 {
130 //set_height();
131
132 // set up sound and particles depending on movement keys
133 if(change & CONTROL_ROT_LEFT)
134 {
135 if(held)
136 {
138 }
139 else
140 {
142 }
143 }
144 else if(change & CONTROL_ROT_RIGHT)
145 {
146 if(held)
147 {
149 }
150 else
151 {
153 }
154 }
155 else if(change & CONTROL_UP)
156 {
157 if(held)
158 {
160 }
161 else
162 {
164 }
165 }
166
167 // do actual action depending on movement keys
168 if(held & change & CONTROL_DOWN)
169 {
170 if(buoyancy > -3)
171 {
172 buoyancy -= 1;
173 if(buoyancy > 0)
174 {
175 llOwnerSay("going up "+llList2String(speeds, (buoyancy - 1))+" speed");
176 }
177 else if(buoyancy < 0)
178 {
179 llOwnerSay("going down "+llList2String(speeds, (-1*buoyancy - 1))+" speed");
180 }
181 else
182 {
183 llOwnerSay("switching airship to hover mode.");
184 }
185 llPlaySound("tick",1);
186 }
187 }
188 else if(held & change & CONTROL_UP)
189 {
190 if(buoyancy < 3)
191 {
192 buoyancy += 1;
193 if(buoyancy > 0)
194 {
195 llOwnerSay("going up "+llList2String(speeds, (buoyancy - 1))+" speed");
196 }
197 else if(buoyancy < 0)
198 {
199 llOwnerSay("going down "+llList2String(speeds, (-1*buoyancy - 1))+" speed");
200 }
201 else
202 {
203 llOwnerSay("switching airship to hover mode.");
204 }
205 llPlaySound("tick",1);
206 }
207 }
208 else if(held & change & CONTROL_FWD)
209 {
210 if(speed < 3)
211 {
212 speed += 1;
213 set_speed("up");
214 }
215 }
216 else if(held & change & CONTROL_BACK)
217 {
218 if(speed > -1)
219 {
220 speed -= 1;
221 set_speed("down");
222 }
223 }
225 {
227 }
229 {
231 }
232 }
233
234 }
235 // END //

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