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 SuperCar  

SuperCar

SuperCar

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

the Zip file

Download all files for SuperCar
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SuperCar_1.lsl
1 // From the book:
2 //
3 // Scripting Recipes for Second Life
4 // by Jeff Heaton (Encog Dod in SL)
5 // ISBN: 160439000
6 X// Copyright 2007 by Heaton Research, Inc.
7 //
8 // This script may be freely copied and modified so long as this header
9 // remains unmodified.
10 //
11 // For more information about this book visit the following web site:
12 //
13 // http://www.heatonresearch.com/articles/series/22/
14
15 float forward_power = 15; //Power used to go forward (1 to 30)
16 float reverse_power = -15; //Power ued to go reverse (-1 to -30)
17 float turning_ratio = 2.0; //How sharply the vehicle turns. Less is more sharply. (.1 to 10)
18 string sit_message = "Ride"; //Sit message
19 string not_owner_message = "You are not the owner of this vehicle ..."; //Not owner message
20 float VERTICAL_THRUST = 7;
21
22 float ROTATION_RATE = 2.0; // Rate of turning
23
24 becomeBoat()
25 {
33
34
35
37 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1);
39
41 llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 5 );
56 }
57
58 becomeCar()
59 {
60 //car
66 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
69 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.5);
74 }
75
76 becomePlane()
77 {
79
84
85 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.2);
88 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
89
92
94
97
101 }
102
103 default
104 {
106 {
107 llSetSitText(sit_message);
108 // forward-back,left-right,updown
109 llSitTarget(<0.2,0,0.45>, ZERO_ROTATION );
110
111 llSetCameraEyeOffset(<-8, 0.0, 5.0>);
112 llSetCameraAtOffset(<1.0, 0.0, 2.0>);
113
114 llPreloadSound("car_start");
115 llPreloadSound("car_run");
116
117 llListen(0, "", NULL_KEY, "");
118
119 becomeCar();
120
121 }
122
123 listen(integer channel, string name, key id, string message)
124 {
125 if( id==llGetOwner() )
126 {
127 if( message == "drive" )
128 becomeCar();
129 else if(message == "fly" )
130 becomePlane();
131 else if(message == "float" )
132 becomeBoat();
133 }
134 }
135
136
137 changed(integer change)
138 {
139
140
141 if(change & CHANGED_LINK)
142 {
143
144 key agent = llAvatarOnSitTarget();
145 if(agent)
146 {
147 if(agent != llGetOwner())
148 {
149 llSay(0, not_owner_message);
150 llUnSit(agent);
151 llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE);
152 }
153 else
154 {
155 llTriggerSound("car_start",1);
156
157 llSay(0,"Welcome to the super car, say 'drive' to make me a car, 'fly' to make me fly, or 'float' to make me a boat.");
158 llSleep(.4);
160 llSleep(.1);
162
163 llLoopSound("car_run",1);
164 }
165 }
166 else
167 {
169
171 llSleep(.1);
172 llMessageLinked(LINK_ALL_CHILDREN , 0, "WHEEL_DEFAULT", NULL_KEY);
173 llSleep(.4);
175 llTargetOmega(<0,0,0>,PI,0);
176
178 }
179 }
180
181 }
182
184 {
185 if(perm) {
187 }
188 }
189
190 control(key id, integer level, integer edge)
191 {
192 integer reverse=1;
193 vector angular_motor;
194
195 //get current speed
196 vector vel = llGetVel();
197 float speed = llVecMag(vel);
198
199
200 //car controls
201 if(level & CONTROL_FWD)
202 {
204 reverse=1;
205 }
206 if(level & CONTROL_BACK)
207 {
209 reverse = -1;
210 }
211
213 {
214 angular_motor.z -= turning_ratio;
215 }
216
218 {
219 angular_motor.z += turning_ratio;
220 }
221
222 if(level & CONTROL_UP) {
224 } else if(edge & CONTROL_UP) {
226 }
227 if(level & CONTROL_DOWN) {
229 } else if(edge & CONTROL_DOWN) {
231 }
232
234
235
236 } //end control
237
238
239 } //end default

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