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 Motor_Yacht_v  

Motor_Yacht_v

Motor Yacht v0.lsl

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

the Zip file

Download all files for Motor_Yacht_v
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Motor_Yacht_v_1.lsl
1
2 // Fixit Galatea generic boat script
3 // This script uses the basic direction keys for boat operation and requires
4 // the final prim to be oriented at rotation <0, 0, 0>. The handling
5
6 // Version of this script
7 float version = 0.82;
8
9 //****************************************************************************
10 //****************************************************************************
11 //****************************************************************************
12 //* The following items can be edited in this script. See the comment for each
13 //* item to see how it work when it is changed.
14 //****************************************************************************
15
16 //* When the forward key is pressed and the mouse button is pressed at the
17 //* same time, this speed is used. This number should be between 0.0 and 30.0,
18 //* with higher numbers giving faster performance.
19 float fastspeed = 30;
20
21 //* When the forward key is pressed and the mouse button is NOT pressed, this
22 //* speed is used. This number should be between 0.0 and whatever the
23 //* fastspeed value was set at, with higher numbers giving faster performance.
24 float slowspeed = 30;
25
26 //* This is the reverse speed. It shouldn't be too fast, but can be between
27 //* 0.0 and 30.0.
28 float backspeed = 10.0;
29
30 //* This is the vehicle 'hover' height, or how far it sits out of the water.
31 //* Adjust this as necessary for your boat.
32 float floatheight = 0.75;
33
34 //* If the boat is to ramp up speed slowly, set the following value to '1'.
35 //* Otherwise, the board will instantly reach full speed when the forward
36 //* key is pressed.
37 integer fastforward = 0; // NOT IMPLEMENTED YET
38
39 //* Turning speed, a small turning speed is best
40 float turnspeed = 1.5;
41
42 //* If the boat 'angles' into turns, set the following value to '1'.
43 //* Otherwise, the boat will do flat turns.
44 integer angledturn = 5; // NOT IMPLEMENTED YET
45
46 //* Height offset of seat
47 vector seatheight = <0.5, -0.55, 0.35>;
48
49 //* Viewing position
50 vector viewpos = <-10, 0, 3>;
51
52 //****************************************************************************
53
54 // Initialize the vehicle as a boat
55 vehicle_init()
56 {
58
59 // least for forward-back, most friction for up-down
61
62 // uniform angular friction (setting it as a scalar rather than a vector)
64
65 // linear motor wins after about five seconds, decays after about a minute
67 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.1);
69
70 // agular motor wins after four seconds, decays in same amount of time
73 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.2);
74
75 // hover
80
81 // Slight linear deflection with timescale of 1 seconds
84
85 // Slight angular deflection
88
89 // somewhat bounscy vertical attractor
92
93 // weak negative damped banking
97
98 // default rotation of local frame
100 llEuler2Rot(<0, 0, 0>));
101
102 // remove these flags
106 // set these flags
111 }
112
113 // Setup everything
114 all_setup()
115 {
116 // Display version number
117 // llWhisper(0, "Motor Yacht script " + (string) version);
119
120 // Set sit direction (forward) and sight location slightly up and behind
121 llSitTarget(seatheight, llEuler2Rot(<0, 0, 0>));
122 llSetCameraAtOffset(<6, 0, 6>);
123 llSetCameraEyeOffset(viewpos);
124 llSetSitText("Ride!");
125
126 // Initialize vehicle states
127 vehicle_init();
128
129 // Set up listener callback function
130 llListen(0, "", llGetOwner(), "");
131 }
132
133 // State (default) event handlers
134 default
135 {
137 {
138 all_setup();
139 }
140
141 on_rez(integer start_param)
142 {
144 }
145
146 run_time_permissions(integer permissions)
147 {
148 // Get user permissions
149 if((permissions & PERMISSION_TAKE_CONTROLS) ==
151 {
155 }
156 }
157
158 changed(integer change)
159 {
160 if(change & CHANGED_LINK)
161 {
162 key agent = llAvatarOnSitTarget();
163 if(agent)
164 {
165 if(agent != llGetOwner())
166 {
167 llSay(0, "This boat isn't yours, but you can buy a copy!");
168 llUnSit(agent);
169 }
170 else
171 {
174 }
175 }
176 else
177 {
180 }
181 }
182 }
183
184 control(key name, integer levels, integer edges)
185 {
186 float side = 0.0;
187 float forw = 0.0;
188 float move = 0.0;
189 float turn;
190
191 if(levels & CONTROL_ML_LBUTTON)
192 {
193 move = fastspeed;
194 turn = 1.5 * turnspeed;
195 // forw = 2 * PI / 3;
196 }
197 else if(levels & CONTROL_FWD)
198 {
199 move = slowspeed;
200 turn = 1.0 * turnspeed;
201 // forw = PI / 2;
202 }
203 else if(levels & CONTROL_BACK)
204 {
205 move = -backspeed;
206 // forw = -PI / 3;
207 // turn = -1.0 * turnspeed;
208 }
209
210 if(levels & (CONTROL_LEFT | CONTROL_ROT_LEFT))
211 {
212 if(move == fastspeed)
213 {
214 side = turnspeed;
215 // forw = PI;
216 }
217 else if(move != 0)
218 {
219 side = turnspeed;
220 // forw = PI / 3;
221 }
222 else
223 {
224 side = .67 * turnspeed;
225 // forw = PI / 4;
226 move = 0.1;
227 }
228 }
230 {
231 if(move == fastspeed)
232 {
233 side = -turnspeed;
234 // forw = PI;
235 }
236 else if(move != 0)
237 {
238 side = -turnspeed;
239 // forw = PI / 3;
240 }
241 else
242 {
243 side = -.67 * turnspeed;
244 // forw = PI / 4;
245 move = 0.1;
246 }
247 }
248
249 if(move == 0)
250 {
252 }
253 else
254 {
256 <move, 0, 0>);
258 <-side / 5, 0, side>);
259 }
260 }
261
262 listen(integer channel, string name, key id, string message)
263 {
264 list params = llParseString2List(message, [" "], [":"]);
265 string cmd = llList2String(params, 0);
266 integer enable = llList2Integer(params, 1);
267
268 // Commands
269 ;
270 }
271
272 touch_start(integer total_number)
273 {
274 key id = llDetectedOwner(total_number - 1);
275 // llGiveInventory(id, "Info card");
276 }
277 }
278 // END //

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