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
Tour Guide Tour Airplane  

Tour Airplane

Tour controller for airplane

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life

the Zip file

Download all files for Tour Airplane
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Autopilot.lsl
Get file # 2. Camera.lsl
Get file # 3. Original Helicopter.lsl
Get file # 4. Random controller.lsl
Get file # 5. Scooter.lsl
Get file # 6. Simple Airplane.lsl
Get file # 7. supercar.lsl
Get file # 8. Tour controller.lsl
Get file # 9. Tour Copter flight.lsl
Get file # 10. Tour Scooter flight.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Revision:
2 // 0.1 8-17-2014 Initial Porting
3 // 0.2 8-22-2014 SL version
4 // 0.3 8-23-2014 Opensim Bulletsim
5
6
7
8 integer debug = FALSE;
9 integer LSLEDITOR = FALSE;
10 integer DEATH = FALSE;
11
12 float SPEED = 10.0; // tunable airplane speed
13
14 integer LINK_CMD = 0;
15 integer LINK_ANIMATE = 1;
16 integer LINK_POSITION = 2;
17 integer LINK_RL = 3;
18 integer LINK_UP = 4;
19 integer LINK_DOWN = 5;
20 integer LINK_SPEED = 6;
21 float TIMER = 0.2;
22 vector lastPos;
23 vector DestPos;
24 integer timerOn;
25
26 // sounds
27 string sDoorClose = "";
28 string sEngineStart = "";
29 string sThrottleUp = "sThrottleUp";
30 string sEngineOn = "sEngineOn";
31
32 DEBUG(string msg) {
33 if(debug) llSay(0,llGetScriptName() + ":" + msg);
34 }
35
36 // Positive to the left, negative to the right, from 0 to PI which is behind you
37
38 //Returns angle the left or right of the baseline vector
39 float left_or_right(vector baseline, vector target)
40 {
41 rotation rot_between = llRotBetween(baseline,target);
42 vector euler_rot = llRot2Euler(rot_between);
43 float z_rot = euler_rot.z;
44 return z_rot;
45 }
46
47
48
49 default
50 {
51 on_rez(integer start_param)
52 {
54 }
56 {
57
58 // the sit and camera placement is very shape dependent
59 // so modify these to suit your vehicle
60 llSitTarget(<0.6, 0.05, 0.20>, ZERO_ROTATION);
61 llSetCameraEyeOffset(<-40.0, 0.0, 10.0> );
62 llSetCameraAtOffset(<3.0, 0.0, 1.0> );
63
64
66 DEBUG("MyPos:" + (string) llGetPos());
67 }
68
69 link_message(integer sender_number, integer number, string message, key id)
70 {
71 // DEBUG("N:" + (string) number + ":" + message);
72
73 if(LINK_POSITION == number && (vector) message != ZERO_VECTOR) {
74 DEBUG("Set New Position:" + message);
75 DestPos = (vector) message;
76 llSetTimerEvent(.01); // get moooving
77
78 } else if(LINK_CMD == number && message == "cStop") {
79 DEBUG("UNSIT");
81
82 }else if(LINK_CMD == number && message == "cStart") {
83 // the plane just started in mid air
84 DEBUG("START");
85 llMessageLinked(LINK_THIS,LINK_SPEED,(string) SPEED,"");
86
87
88 } else if(LINK_CMD == number && message == "Die") {
89 DEBUG("Die");
91 if(DEATH)
92 llDie();
93
94 } else if(LINK_CMD == number && message == "cShutdown") {
95 timerOn = FALSE;
97
98 DEBUG("Plane position set to " + message);
100 llSleep(0.1); // time to settle down
101 if(DestPos != ZERO_VECTOR)
102 llSetRegionPos(DestPos);
103
104 } else if(LINK_CMD == number && message == "cDoorOpen") {
105 DEBUG("Door Open");
106 llMessageLinked(LINK_THIS,LINK_ANIMATE,"AllDoorsOpen","");
107
108 } else if(LINK_CMD == number && message == "cDoorClose") {
109 DEBUG("Door Close");
110 llMessageLinked(LINK_THIS,LINK_ANIMATE,"AllDoorsClosed","");
111
112 } else if(LINK_CMD == number && (llGetInventoryType(message) == INVENTORY_SOUND) ) {
113 DEBUG("Playing sound:" + message);
114 llLoopSound(message,1.0);
115
116 if( message == "sEngineStart")
117 llPreloadSound(sThrottleUp);
118 else if( message == "sThrottleUp")
119 llPreloadSound(sEngineOn);
120
121 }
122 }
123
124 timer()
125 {
126 vector Pos = DestPos - llGetPos();
127 // DEBUG("Pos:" + (string) Pos);
128
129 float dist = llVecDist(llGetPos(),lastPos);
130 /// DEBUG("Distance:" + (string) dist);
131
132 lastPos = llGetPos();
133
134
135 if(DestPos.z > lastPos.z)
136 llMessageLinked(LINK_THIS,LINK_UP,"","");
137 else
138 llMessageLinked(LINK_THIS,LINK_DOWN,"","");
139
140
141 if(dist < SPEED)
142 DEBUG("Go faster:" + (string) (SPEED - dist));
143 llMessageLinked(LINK_THIS,LINK_SPEED,(string) (SPEED - dist),"");
144 if(dist > SPEED) {
145 DEBUG("Go slower");
146 llMessageLinked(LINK_THIS,LINK_SPEED,"-0.1","");
147 }
148
149 //Is the detected position to the left or the right of this object's current heading?
150 float target_L_or_R = left_or_right(llRot2Fwd(llGetRot()),Pos);
151
152 llMessageLinked(LINK_THIS,LINK_RL,(string) target_L_or_R,"");
153 if(LSLEDITOR)
155 else
156 llSetTimerEvent(TIMER);
157 }
158
159
160
161 }

Tour Airplane

Tour conteoller for airplane

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2
3 // Revision:
4 // 0.1 8-17-2014 Initial Porting
5 // 0.2 8-22-2014 SL version
6 // 0.3 8-23-2014 Opensim Bulletsim
7
8
9 integer debug = FALSE;
10 integer LSLEDITOR = FALSE;
11
12
13 integer LINK_CMD = 0;
14 integer LINK_ANIMATE = 1;
15 integer LINK_POSITION = 2;
16 integer LINK_RL = 3;
17 integer LINK_UD = 4;
18 integer LINK_SPEED = 5;
19
20 float TIMER = 1;
21 integer MAX_TIME = 60;
22
23 float MAX_DIST = 10.0; // how close to the target we have to be to consider it a successful trip.
24
25 integer timeout = 0; // if we cannot reach a spot, then move on
26 vector TargetLocation; // where we are headed, my be NULL_VECTOR
27
28
29 DEBUG(string msg) { if(debug) llSay(0,llGetScriptName() + ":" + msg); }
30
31 vector New()
32 {
33 float x = llFrand(150) + 50;
34 float y = llFrand(150) + 50;
35 float z = llFrand(50) + 35;
36 return <x,y,z>;
37
38 }
39
40 default
41 {
42
43 on_rez(integer param)
44 {
46 }
47
48
49 changed(integer what)
50 {
51 if(what & CHANGED_LINK)
52 {
53 key avatarKey = llAvatarOnSitTarget();
54 if(avatarKey != NULL_KEY) {
55 llSay(0,"Please stay seated");
56 llMessageLinked(LINK_THIS,LINK_CMD,"cStart","");
57
58 llSetTimerEvent(TIMER);
59
60 } else {
61 llSay(0,"Please stay seated, click the airplane!");
62
63 llMessageLinked(LINK_THIS,LINK_CMD,"cStop","");
65 }
66
67 }
68 }
69
70
71 timer()
72 {
73
74 DEBUG("Goto:" + (string) TargetLocation);
75 vector myPos = llGetPos();
76
77
78 if(LSLEDITOR)
79 myPos = TargetLocation;
80
81 if(llVecDist(myPos, TargetLocation) > MAX_DIST && TargetLocation != ZERO_VECTOR)
82 {
83 if(timeout++ > MAX_TIME) // Time Out to contingency
84 {
85 timeout = 0;
86 DEBUG("New Target");
87 TargetLocation = New();
88
89 llMessageLinked(LINK_THIS,2,(string) TargetLocation,"");
90
91 }
92
93 } else {
94
95 timeout = 0;
96 TargetLocation = New();
97
98 DEBUG("*************** FlyTo: " + (string) TargetLocation);
99 llMessageLinked(LINK_THIS,LINK_POSITION,(string) TargetLocation,"");
100 }
101 }
102 }

Tour Airplane

Opensim Scooter

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 //Final code and animations and sounds by Christy Lock OSGRID 4/23/2014
2 //Maegan OMally standalone alt may be listed also
3
4 //Special Thanks to Robert Adams and all those who worked on BulletSim!
5 //BulletSim Required for this to work
6 //Thanks to Cory and ANdrew Linden as their work and instructions contributed to this code
7
8 //EVERYTHING in the scooter is opensource free to use as you like
9
10
11 key agent;
12
13 integer handle;
14
15 float forward_power = 35.0; //Power used to go forward
16 float reverse_power = -25.0; //Power ued to go reverse
17 float turn_rate = 15.0;//rotation (twist) around angular.z
18
19 string sit_message = "Scoot"; //Sit message
20
21 vector linear;
22 vector angular;
23
24 float xfactor = 28.0;//Normal velocity all three axis
25 float yfactor = 8.0;
26 float zfactor = 12.0;
27
28 dialog(key user)
29 {
30 handle = llListen(-2,"",user,"");
31 llDialog(user,"Options",["normal","slow"],-2);
32 }
33
34 cam()
35 {
36 //extra camera code for testing
38 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
39 CAMERA_BEHINDNESS_ANGLE, 95.0, // (0 to 180) degrees
40 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
41 CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
42 //CAMERA_FOCUS, <0,0,5>, // region relative position
43 CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
44 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
45 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
46 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 20.0, // (-45 to 80) degrees
47 //CAMERA_POSITION, <0,0,0>, // region relative position
48 CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
49 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
50 CAMERA_POSITION_THRESHOLD, 2.0, // (0 to 4) meters
51 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
52 ]);
53 }
54 camfixed()
55 {
56 //actual camera used....Camera_Position_Lag should be 0.0 0.1 makes the cam bump a little
57 //and look like the physics engine is on off on off - same for Camera_behindness_lag
59 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
60 CAMERA_BEHINDNESS_ANGLE, 95.0, // (0 to 180) degrees
61 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
62 CAMERA_DISTANCE, 7.0, // ( 0.5 to 10) meters
63 //CAMERA_FOCUS, <0,0,5>, // region relative position
64 CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
65 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
66 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
67 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 20.0, // (-45 to 80) degrees
68 //CAMERA_POSITION, <0,0,0>, // region relative position
69 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
70 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
71 CAMERA_POSITION_THRESHOLD, 2.0, // (0 to 4) meters
72 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
73 ]);
74 }
75 driving_cam360()
76 {
77 //extra camera code for testing
79 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
80 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
81 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
82 CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
83 //CAMERA_FOCUS, <0,0,5>, // region relative position
84 CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
85 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
86 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
87 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 20.0, // (-45 to 80) degrees
88 //CAMERA_POSITION, <0,0,0>, // region relative position
89 CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
90 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
91 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
92 CAMERA_FOCUS_OFFSET, <0,0,-2.0> // <-10,-10,-10> to <10,10,10> meters
93 ]);
94 }
95 driving_cam90()
96 {
97 //extra camera code for testing
99 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
100 CAMERA_BEHINDNESS_ANGLE, 95.0, // (0 to 180) degrees
101 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
102 CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
103 //CAMERA_FOCUS, <0,0,5>, // region relative position
104 CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
105 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
106 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
107 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 20.0, // (-45 to 80) degrees
108 //CAMERA_POSITION, <0,0,0>, // region relative position
109 CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
110 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
111 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
112 CAMERA_FOCUS_OFFSET, <0,0,0> // <-10,-10,-10> to <10,10,10> meters
113 ]);
114 }
115
116 init()
117 {
118 llPreloadSound("jetstartupfinal");
119 llPreloadSound("jetloopfinal");
120 llPreloadSound("jetshutdownfinal");
121
123
124 //ANGULAR MOTOR **
125 // somewhat responsive angular motor, but with 3 second decay timescale
127 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 3);
128
129 // weak angular deflection
132
133 //weak friction all 3 axis
135
136 ;
137
138 //* LINEAR MOTOR **
139 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);//0.5
141
142 //moderate - weakish linear deflection
145
146 //weak friction for linear motor also
148
149
150
151
152 //** VERTICAL ATTRACTOR **
155
156 //** BANKING STRENGTH and MIX for speed
157 llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.4);//0.4 // medium strength
158 llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.8);//0.1//0.8 // very responsive
159 llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 0.95);//0.95 // more banking when moving
160
161
162 //** 1.0 floats and turn on physics **
165
166 }
167
168 release_camera_control()
169 {
170 llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive
171 }
172
173 default
174 {
176 {
177 llMessageLinked(LINK_SET,-1,"Tstop","");//stop particles and turbine spin
178 llSetSitText(sit_message);
179 llSitTarget(<-0.02,0.0,-0.15>, ZERO_ROTATION );
182 }
183 touch_start(integer touched)
184 {
185 key avatar = llDetectedKey(0);
186 dialog(avatar);
187 }
188 listen(integer chan,string name,key id , string msg)
189 {
190 if( msg == "normal")
191 {
192 llOwnerSay( "Normal speed");
193 xfactor = 28.0;
194 yfactor = 8.0;
195 zfactor = 12.0;
196 llListenRemove(handle);
197 }
198 else if( msg == "slow")
199 {
200 llOwnerSay( "Slow speed");
201 xfactor = 10.0;
202 yfactor = 4.0;
203 zfactor = 4.0;
204 llListenRemove(handle);
205 }
206 }
207 changed(integer change)
208 {
209 if(change & CHANGED_LINK)
210 {
211 agent = llAvatarOnSitTarget();
212
213 if(agent != NULL_KEY)
214 {
216 llStartAnimation("Moto6 p4 loop");
217
218 llTriggerSound("jetstartupfinal",1.0);
219 llLoopSound("jetloopfinal",1.0);
220
221 init();
222 camfixed();
223 llMessageLinked(LINK_SET,-1,"Tstart","");
224 }
225 else
226 {
227 llMessageLinked(LINK_SET,-1,"Tstop","");
228 llTriggerSound("jetshutdownfinal",1.0);
229 llSleep(0.2);
230 release_camera_control();
233 }
234 }
235 }
237 {
238 if(perm)
239 {
241
242 }
243 }
244
245 control(key name, integer levels, integer edges)
246 {
247 if((edges & levels & CONTROL_UP))
248 {
249 linear.z += zfactor;
250 }
251 else if((edges & ~levels & CONTROL_UP))
252 {
253 linear.z -= zfactor;
254 }
255 if((edges & levels & CONTROL_DOWN))
256 {
257 linear.z -= zfactor;
258 }
259 else if((edges & ~levels & CONTROL_DOWN))
260 {
261 linear.z += zfactor;
262 }
263 if((edges & levels & CONTROL_FWD))
264 {
265 linear.x += xfactor;
266 }
267 else if((edges & ~levels & CONTROL_FWD))
268 {
269 linear.x -= xfactor;
270 }
271 if((edges & levels & CONTROL_BACK))
272 {
273 linear.x -= xfactor;
274 }
275 else if((edges & ~levels & CONTROL_BACK))
276 {
277 linear.x += xfactor;
278 }
279
280 if((edges & levels & CONTROL_LEFT))
281 {
282 linear.y += yfactor;
283 llStartAnimation("Moto6_left_Remake1 p4 nl");
284 }
285 else if((edges & ~levels & CONTROL_LEFT))
286 {
287 linear.y -= yfactor;
288 }
289 if((edges & levels & CONTROL_RIGHT))
290 {
291 linear.y -= yfactor;
292 llStartAnimation("Moto6_right_Remake1 p4 nl");
293 }
294 else if((edges & ~levels & CONTROL_RIGHT))
295 {
296 linear.y += yfactor;
297 }
298 if((edges & levels & CONTROL_ROT_LEFT))
299 {
300
301 angular.z += turn_rate;
302 angular.x -= PI * 3;
303 llStartAnimation("Moto6_left_Remake1 p4 nl");
304 }
305 else if((edges & ~levels & CONTROL_ROT_LEFT))
306 {
307 angular.z -= turn_rate;
308 angular.x += PI * 3;
309 }
310 if((edges & levels & CONTROL_ROT_RIGHT))
311 {
312 angular.z -= turn_rate;
313 angular.x += PI * 3;
314 llStartAnimation("Moto6_right_Remake1 p4 nl");
315 }
316 else if((edges & ~levels & CONTROL_ROT_RIGHT))
317 {
318 angular.z += turn_rate;
319 angular.x -= PI * 3;
320 }
323 }
324 }

Tour Airplane

Camera controller

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 release_camera_control()
2 {
3 llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive
4 }
5
6
7 spin_cam()
8 {
10 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
11 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
12 CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
13 //CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
14 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
15 CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
16 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
17 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
18 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 30.0, // (-45 to 80) degrees
19 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
20 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
21 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
22 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
23 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
24 ]);
25
26 float i;
27 vector camera_position;
28 for (i=0; i< 2*TWO_PI; i+=.05)
29 {
30 camera_position = llGetPos() + <0.0, 4.0, 0.0> * llEuler2Rot(<0.0, 0.0, i>);
31 llSetCameraParams([CAMERA_POSITION, camera_position]);
32 }
33 focus_on_me();
34 }
35
36
37
38
39 focus_on_me()
40 {
41 llOwnerSay("focus_on_me"); // say function name for debugging
42 // llClearCameraParams(); // reset camera to default
43 vector here = llGetPos();
45 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
46 CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
47 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
48 CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
49 CAMERA_FOCUS, here, // region relative position
50 CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
51 CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
52 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
53 // PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 80.0, // (-45 to 80) degrees
54 CAMERA_POSITION, here + <4.0,4.0,4.0>, // region relative position
55 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
56 CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
57 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
58 CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters
59 ]);
60
61
62 }
63
64
65 CameraOut()
66 {
68 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
69 CAMERA_BEHINDNESS_ANGLE, 2.0, // (0 to 180) degrees
70 CAMERA_BEHINDNESS_LAG, 0.2, // (0 to 3) seconds
71 CAMERA_DISTANCE, 20.0, // ( 0.5 to 10) meters
72 //CAMERA_FOCUS, <0,0,5>, // region relative position
73 CAMERA_FOCUS_LAG, 0.02 , // (0 to 3) seconds
74 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
75 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
76 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 0.0, // (-45 to 80) degrees
77 //CAMERA_POSITION, <0,0,0>, // region relative position
78 CAMERA_POSITION_LAG, 0.15, // (0 to 3) seconds
79 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
80 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
81 CAMERA_FOCUS_OFFSET, <0,0,1> // <-10,-10,-10> to <10,10,10> meters
82 ]);
83 }
84
85
86 default
87 {
88
89
90 changed(integer change)
91 {
92 if(change & CHANGED_LINK)
93 {
94 key agent = llAvatarOnSitTarget();
95
96 if(agent != NULL_KEY)
97 {
99 }
100 else
101 {
102 release_camera_control();
103 }
104 }
105 }
106
108 {
110 {
111 focus_on_me();
112 llSleep(2);
113 CameraOut();
114 }
115 }
116
117
118
119
120
121 }

Tour Airplane

Route notecard holds the coords for the tour

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 notecard|<0,0,0>|cStart
2 notecard|<0,0,0>|sEngineOn
3 notecard|<100,100,100>|tWelcome
4 notecard|<100,500,100>|tLanding
5 notecard|<500,100,100>|sEngineOff
6 notecard|<500,100,100>|sLand
7 notecard|<250,250,100>|cShutdown
8 notecard|<0,0,0>|cDoorOpen
9 notecard|<0,0,0>|cPause
10 notecard|<0,0,0>|cDoorClose
11 notecard|<0,0,0>|sEngineStart
12 notecard|<0,0,0>|sThrottleUp
13 notecard|<250,100,100>|
14 notecard|<100,100,101>|
15 notecard|<0,0,0>|Die

Tour Airplane

Airplane script for tour plane

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // originally edited by Andrew Linden on 12-08-2003 at 02:31 PM
3 // revisions
4 // Revision:
5 // 0.1 8-17-2014 Initial Porting
6 // 0.2 8-22-2014 SL version
7 // 0.3 8-23-2014 Opensim Bulletsim
8
9
10
11
12 // assumes that the root primitive is oriented such that its
13 // local x-axis points toward the nose of the plane, and its
14 // local z-axis points toward the top
15
16 integer debug = FALSE;
17
18 DEBUG(string msg) {
19 if(debug) llSay(0,llGetScriptName() + ":" + msg);
20 }
21
22
23 integer LINK_CMD = 0;
24 integer LINK_ANIMATE = 1;
25 integer LINK_POSITION = 2;
26 integer LINK_RL = 3;
27 integer LINK_UD = 4;
28 integer LINK_SPEED = 5;
29
30 float LR = 10.0; // mutiplier for Left/right
31
32 //if the root primitive of your airplane does not have the same orientation as the whole airplane
33 //(i.e. local x-axis = forward, local y-axis = left, local z-axis = up) then the script will not push
34 //your airplane in the "correct" direction.
35 //
36 //You need to either:
37 //
38 //1. orient your root primitive to agree with the airplane's axes of motion
39 //2. pick a different primitive to be the root (one whose local axes agree with those of the airplane's motion)
40 //3. use the VEHICLE_REFERENCE_FRAME parameter (this is an advanced topic and is outside the scope of a _simple_ airplane script)
41
42
43 // the linear motor uses an accumulator model rather than keeping track
44 // of the linear control level history
45 vector gLinearMotor = <0, 0, 0>;
46
47
48
49 default
50 {
51
52 on_rez(integer p) {
54 }
55
57 {
59 llCollisionSound("", 0.0);
60
62
63 // weak angular deflection
66
67 // somewhat responsive angular motor, but with 3 second decay timescale
69 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 3); // 3
71
72 // strong linear deflection
75
76 // somewhat responsive linear motor
77 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.5); // VEHICLE_LINEAR_MOTOR_TIMESCALE is the time for motor to "win". Determines how long it takes for the motor to push the vehicle to full speed. Its minimum value is approximately 0.06 seconds.
78 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 20); // is the time for the motor's "effectiveness" to decay toward zero. The effectiveness of the motor will exponentially decay over this timescale, but the effectiveness will be reset whenever the motor's value is explicitly set. The maximum value of this decay timescale is 120 seconds, and this timescale is always in effect.
79 // very weak friction
81
82
85
86 //llSetVehicleFlags(VEHICLE_FLAG_LIMIT_ROLL_ONLY|VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT); // to make a airplane you would probably want to unlock the attractor around the pitch axis by setting the VEHICLE_FLAG_LIMIT_ROLL_ONLY bit
87
88 llSetVehicleFlags(VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT); // to make a airplane you would probably want to unlock the attractor around the pitch axis by setting the VEHICLE_FLAG_LIMIT_ROLL_ONLY bit
89
90 llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, .8); // medium strength = 0.4
92 llSetVehicleFloatParam(VEHICLE_BANKING_MIX, .05); // more banking when moving
93
94
95 // hover can be better than sliding along the ground during takeoff and landing
96 // but it only works over the terrain (not objects)
97
98 vector pos = llGetPos();
99 float H = pos.z;
100
102
106
107 // non-zero buoyancy helps the airplane stay up
108 // set to zero if you don't want this crutch
110
111
112 }
113
114
115
116 link_message(integer sender_number, integer number, string message, key id)
117 {
118 //DEBUG("N:" + (string) number + ":" + message);
119 vector motor;
120
121 if(number == LINK_CMD && message == "cStart") {
122
124 llSleep(.01);
125 // clear linear motor on successful sit
126 gLinearMotor = <0, 0, 0>;
130
131 } else if(number == LINK_CMD && message == "cStop") {
132 // stop the motors
133 gLinearMotor = <0, 0, 0>;
136
137 // use friction to stop the vehicle rather than pinning it in place
141
142 } else if(number == LINK_SPEED){
143
144 gLinearMotor.x += (float) message;
145
146 if(gLinearMotor.x > 10) // maximum of 10 from the wiki
147 gLinearMotor.x = 10;
148
149 if(gLinearMotor.x < 0)
150 gLinearMotor.x = 0;
151
152 // DEBUG("SPEED:" + (string) gLinearMotor.x );
154
155 } else if(number == LINK_RL) {
156
157 // from 0 to PI which is behind you
158 float angle = (float) message;
159 DEBUG("Angle:" + (string) angle);
160
161 if( angle > 0) {
162 motor.x = -angle * LR;
163 DEBUG("Left:" + (string) motor.x);
164 } else {
165 motor.x = -angle * LR;
166 DEBUG("Right:" + (string) motor.x);
167 }
169
170 } else if(number == LINK_UD) {
171 float height = (float) message;
172 DEBUG("Height:" + (string) height);
174 }
175 }
176 }

Tour Airplane

Opensim Supercar

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 //*******************************************************
2 // Shin Ingen @ http://ingen-lab.com:8002
3 // LSL | OPENSIM | BulletSim and ODE | ACDC
4 // iTEC + e3s + DC (ENGINE SPEED SENSITIVE STEERING WITH DYNAMIC CAMERA)
5 // JANUARY 28, 2013
6 // TODO: KEYWORD PROCESSOR FOR ** PRIM ANIMATION | AVATAR ANIMATION | SOUNDS | MENU | HUD | DYNAMIC CAMERA
7 //*******************************************************
8
9 //---PERMISSION VARIABLES---------------------------------------------
10 integer gDrivePermit = 1; // 0=EVERYONE 1=OWNERONLY
11 string gSitMessage = "Drive";
12 string gUrNotAllowedMessage = "Vehicle is Locked";
13 vector gSitTarget_Pos = <-0.25,2.1,1.25>;
14 vector gSitTarget_Rot;
15 key gOldAgent;
16 key gAgent;
17 integer gRun; //ENGINE RUNNING
18 integer gMoving; //VEHICLE MOVING
19 //integer gIdle;
20 //---END PREMISSION----------------------------------------------------
21
22 //---ANIMATION VARIABLES-----------------------------------------------
23 string gDrivingAnim = "driverLH-64-64";
24 //---------------------------------------------------------------------
25
26 //---CAMERA VARIABLES--------------------------------------------------
27 //***CONSTANT**********************************************************
28 integer gCamFixed=0; // INITVAL=0 0=FOLLOW CAM 1=FIXED CAM
29 //integer gCamAct; // INITVAL=1 0=INACTIVE 1=ACTIVE
30 //integer gCamFocLocked; // INITVAL=FALSE (TRUE or FALSE)
31 //integer gCamPoslocked; // INITVAL=FALSE (TRUE or FALSE)
32 //***SLIDERS***********************************************************
33 //float gCamBAng; // INITVAL=2.0 (0 to 180) DEGREES
34 //float gCamBLag; // INITVAL=0.1 (0 to 3) SECONDS
35 //float gCamDist; // INITVAL=8.0 (0.5 to 10) METERS
36 //float gCamFocLag; // INITVAL=0.1 (0 to 3) SECONDS
37 //float gCamFocThresh; // INITVAL=0.5 (0 to 4) METERS
38 //float gCamPitch; // INITVAL=20.0 (-45 to 80) DEGREES
39 //float gCamPoslag; // INITVAL=0.1 (0 to 3) SECONDS
40 //float gCamPosthresh; // INITVAL=0.5 (0 to 4) METERS
41 //vector gCamFocOff; // INITVAL=<0.10,0,0> <-10,-10,-10> to <10,10,10> METERS
42 //----END CAMERA-------------------------------------------------------
43
44 //---SOUND VARIABLES---------------------------------------------------
45 string gSoundFlight = "s_flight";
46 string gSoundHorn = "s_horn";
47 string gSoundStartup = "s_startup";
48 string gSoundIdle = "s_idle";
49 string gSoundSlow = "s_slow";
50 string gSoundAggressive = "s_fast";
51 string gSoundGearUp = "s_gearup";
52 string gSoundGearDown = "s_geardown";
53 string gSoundRev = "s_rev";
54 string gSoundAlarm = "s_alarm";
55 string gSoundStop = "s_rev";
56 //NEED KEYWORD SOUND PROCESSOR
57 integer gOldSound=3; //variable for sound function
58 integer gNewSound=3;
59 //---------------------------------------------------------------------
60
61 //---iTEC - STOCK ENGINE GLOBAL VARIABLES------------------------------
62 list gTSvarList;
63 float gVLMT=0.90; //INITVAL=0.90
64 float gVLMDT=0.10; //INITVAL=0.10
65 vector gVLFT=<8.0, 3000.0, 8.0>; //INITVAL=<8.0, 3000.0, 8.0>
66 vector gVAFT=<0.10, 0.10, 0.10>; //INITVAL=<0.10, 0.10, 0.10>
67 float gVADE=0.20; //INITVAL=0.20
68 float gVADT=0.50; //INITVAL=0.10
69 float gVAMT=1.0; //INITVAL=0.10
70 float gVAMDT=0.10; //INITVAL=0.10
71 float gVLDE=1.0; //INITVAL=1.0
72 float gVLDT=0.10; //INITVAL=0.10
73 float gVVAE=0.50; //INITVAL=0.50
74 float gVVAT=5.0; //INITVAL=5.0
75 float gVHE=0.0; //INITVAL=0.0
76 float gVHT=0.0; //INITVAL=0.0
77 float gVHH=0.0; //INITVAL=0.0
78 float gVB=0.0; //INITVAL=0.0
79 //---------------------------------------------------------------------
80
81 //---iTEC POWERTRAIN + (e3s) GLOBAL VARIABLES -------------------------
82 integer gGear;
83 //integer gNewGear;
84 float gGearPower;
85 float gReversePower = -15;
86 list gGearPowerList = [ 2, // STAGER
87 15, // BURNOUT
88 20, // 1ST
89 40, // 2ND
90 70, // 3RD
91 80, // 4TH
92 100, // 5TH
93 110, // 6TH
94 155, // PRO-STOCK (START-DRAG-CLASS)
95 170, // PRO-MOD
96 198, // TOP-FUEL
97 256 // OPEN-PRO
98 ];
99 //integer gGearCount;
100 //string gPhysEngDesc;
101 integer gPhysEng=1; // if os function is off set this to 0=ODE| 1=Bullet
102 float gTurnMulti=1.012345;
103 float gTurnRatio;
104 list gTurnRatioList;
105 string gGearName;
106 list gGearNameList =[ "STAGER",
107 "BURNOUT",
108 "1ST-GEAR",
109 "2ND-GEAR",
110 "3RD-GEAR",
111 "4TH-GEAR",
112 "5TH-GEAR",
113 "6TH-GEAR",
114 "PRO-STOCK",
115 "PRO-MOD",
116 "TOP-FUEL",
117 "OPEN-PRO"
118 ];
119 float gSpeed=0;
120 //---------------------------------------------------------------------
121
122 //---------------------------------------------------------------------
123 //NEED A KEYWORD PRIM ANIMATION PROCESSOR
124 integer gTurnCount;
125 string gTurnAngle = "NoTurn"; // LeftTurn or RightTurn or NoTurn
126 string gNewTurnAngle = "NoTurn";
127 string gTireSpin = "ForwardSpin"; // ForwardSpin or BackwardSpin or NoSpin
128 string gNewTireSpin = "ForwardSpin";
129
130 integer gTcountL; //for cornerF
131 Xinteger gTcountR;
132
133 //---------------------------------------------------------------------
134
135 //---MENU HANDLER------------------------------------------------------
136 list MENU_MAIN = ["Align", "Hello"]; // up to 12 items in list
137 integer menu_handler;
138 integer menu_channel;
139 //---------------------------------------------------------------------
140
141 //=======================================================================
142 //==== E N D G L O B A L V A R I A B L E D E C L A R A T I O N ====
143 //=======================================================================
144 init_TSvar(integer i){
145 if(i==0){
146 gTSvarList = [ 3.0, // how fast to reach max speed
147 0.10, // how fast to reach min speed or zero
148 <7.0,3000.0,100.0>, // XYZ linear friction
149 <0.10,0.10,0.20>, // XYZ angular friction
150 0.90, // how fast turning force is applied
151 0.50, // how fast turning force is released
152 1.0, // adjusted on 0.7.6
153 0.10,
154 0.20,
155 0.10,
156 0.50,
157 5.0,
158 0.0,
159 0.0,
160 0.0,
161 0.0
162 ];
163 }else{
164 gTSvarList = [ 1.0, // how fast to reach max speed
165 0.10, // how fast to reach min speed or zero
166 <8.0,3000.0,8.0>, // XYZ linear friction
167 <0.10,0.10,0.10>, // XYZ angular friction
168 0.20, // how fast turning force is applied
169 0.20, // how fast turning force is released
170 0.80, // adjusted on 0.8.0
171 0.10,
172 1.0,
173 0.10,
174 0.50,
175 5.0,
176 0.0,
177 0.0,
178 0.0,
179 0.0
180 ];
181 }
182 gVLMT=llList2Float(gTSvarList,0);
183 gVLMDT=llList2Float(gTSvarList,1);
184 gVLFT=llList2Vector(gTSvarList,2);
185 gVAFT=llList2Vector(gTSvarList,3);
186 gVAMT=llList2Float(gTSvarList,4);
187 gVAMDT=llList2Float(gTSvarList,5);
188 gVLDE=llList2Float(gTSvarList,6);
189 gVLDT=llList2Float(gTSvarList,7);
190 gVADE=llList2Float(gTSvarList,8);
191 gVADT=llList2Float(gTSvarList,9);
192 gVVAE=llList2Float(gTSvarList,10);
193 gVVAT=llList2Float(gTSvarList,11);
194 gVHE=llList2Float(gTSvarList,12);
195 gVHT=llList2Float(gTSvarList,13);
196 gVHH=llList2Float(gTSvarList,14);
197 gVB=llList2Float(gTSvarList,15);
198
199 }
200
201 init_PhysEng(){
202 string msg;
203 //gPhysEngDesc=osGetPhysicsEngineType();
204 //if(gPhysEngDesc=="OpenDynamicsEngine"){
205 // msg ="Your Vehicle is tuned for OpenDynamicsEngine";
206 // gPhysEng=0;
207 //}else if(gPhysEngDesc=="BulletSim"){
208 // msg ="Your Vehicle is tuned for BulletSim";
209 // gPhysEng=1;
210 //}else{
211 // msg ="WARNING:Automatic Detection of Physics Engine is off.";
212 //}
213 if(gPhysEng==0){
214 msg =":: is tuned for OpenDynamicsEngine";
215 }else if(gPhysEng==1){
216 msg =":: is tuned for BulletSim";
217 }
218
219 if(gPhysEng==0){
220 // gTurnMulti=gTurnMulti;
221 init_TSvar(0);
222 gTurnRatioList = [ 2.4, // STAGER
223 2.4, // BURNOUT
224 2.4, // 1ST
225 2.5, // 2ND
226 4.2, // 3RD
227 4.7, // 4TH
228 5.5, // 5TH
229 6.5, // 6TH
230 7.5, // PRO-STOCK (START-DRAG-CLASS)
231 10.0, // PRO-MOD
232 10.0, // TOP-FUEL
233 10.0 // OPEN-PRO
234 ];
235 gGearPowerList = [ 2, // STAGER
236 10, // BURNOUT
237 15, // 1ST
238 30, // 2ND
239 60, // 3RD
240 70, // 4TH
241 90, // 5TH
242 110, // 6TH
243 155, // PRO-STOCK (START-DRAG-CLASS)
244 170, // PRO-MOD
245 200, // TOP-FUEL
246 256 // OPEN-PRO
247 ];
248
249
250 }else{
251 gTurnMulti=0.987654;
252 init_TSvar(1);
253 gTurnRatioList = [ 1.3, // STAGER
254 1.5, // BURNOUT
255 1.5, // 1ST
256 2.5, // 2ND
257 3.9, // 3RD
258 4.0, // 4TH
259 4.1, // 5TH
260 4.5, // 6TH
261 10.0, // PRO-STOCK (START-DRAG-CLASS)
262 10.0, // PRO-MOD
263 10.0, // TOP-FUEL
264 10.0 // OPEN-PRO
265 ];
266
267 gGearPowerList = [ 2, // STAGER
268 15, // BURNOUT
269 20, // 1ST
270 40, // 2ND
271 70, // 3RD
272 80, // 4TH
273 100, // 5TH
274 110, // 6TH
275 155, // PRO-STOCK (START-DRAG-CLASS)
276 170, // PRO-MOD
277 198, // TOP-FUEL
278 256 // OPEN-PRO
279 ];
280
281 }
282 llSay(0,msg);
283 }
284
285 preload_sounds(){
286 llPreloadSound(gSoundFlight);
287 llPreloadSound(gSoundHorn);
288 llPreloadSound(gSoundStartup);
289 llPreloadSound(gSoundIdle);
290 llPreloadSound(gSoundSlow);
291 llPreloadSound(gSoundAggressive);
292 llPreloadSound(gSoundGearUp);
293 llPreloadSound(gSoundGearDown);
294 llPreloadSound(gSoundRev);
295 llPreloadSound(gSoundAlarm);
296 }
297
298 init_engine(){
299 gRun = 0;
300 llSetSitText(gSitMessage);
301 llCollisionSound("", 0.0);
302 gSitTarget_Rot = llRot2Euler( llGetRootRotation() ); // SIT TARGET IS BASED ON VEHICLE'S ROTATION.
303 llSitTarget(gSitTarget_Pos, llEuler2Rot(DEG_TO_RAD * gSitTarget_Rot));
304 gOldSound=3;
305 gNewSound=3;
306 gTireSpin = "NoSpin";
307 gTurnAngle = "NoTurn";
308 llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
309 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY); // NO SPIN
310 llMessageLinked(LINK_SET, 0, gTurnAngle, NULL_KEY); // NO TURN
311 }
312
313 init_followCam(float degrees){
315 CAMERA_ACTIVE, 1, // 0=INACTIVE 1=ACTIVE
316 CAMERA_BEHINDNESS_ANGLE, 4.0, // (0 to 180) DEGREES
317 CAMERA_BEHINDNESS_LAG, 0.02, // (0 to 3) SECONDS
318 CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) METERS
319 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 8.0, // (-45 to 80) DEGREES
320 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
321 CAMERA_POSITION_LAG, 0.000, // (0 to 3) SECONDS
322 CAMERA_POSITION_THRESHOLD, 8.0, // (0 to 4) METERS
323 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
324 CAMERA_FOCUS_LAG, 0.00 , // (0 to 3) SECONDS
325 CAMERA_FOCUS_THRESHOLD, 8.0, // (0 to 4) METERS
326 CAMERA_FOCUS_OFFSET, <0.10,0,0> // <-10,-10,-10> to <10,10,10> METERS
327 ]);
328 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
329 llSetCameraEyeOffset(<-10, 0, 3.5> * sitRot);
330 llSetCameraAtOffset(<4, 0, 3> * sitRot);
332 }
333
334 init_fixedCam(float degrees) {
335 rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI);
336 llSetCameraEyeOffset(<-10, 0, 3.5> * sitRot);
337 llSetCameraAtOffset(<4, 0, 3> * sitRot);
339 }
340
341 set_engine(){
347 llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <2.00000, 0.00000, 0.00000, 0.00000>);
348 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, gVLMT);
353 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, gVAMDT);
364
368 }
369
370 powershift(integer g){
371 if(!gMoving){
372 if(gCamFixed==0){
373 //enter your cam logic here
374 }
375 }
376 else {
377 vector vel = llGetVel();
378 float speed = llVecMag(vel);
379 if(speed <=20){
380 if(gCamFixed==0){
381 //enter your cam logic here
382 }
383 }
384 else if((speed >=21) || (speed <=50)){
385 if(gCamFixed==0){
386 //enter your cam logic here
387 }
388 }
389 else if(speed >=51) {
390 if(gCamFixed==0){
391 //enter your cam logic here
392 }
393
394 }
395 }
396 gGearPower = llList2Integer(gGearPowerList, g);
397 }
398
399 gearshift(integer g){
400 gGearName = llList2String(gGearNameList, g);
401 enginesound();
402 llSay(0,gGearName);
403 }
404
405 nearestpi(){
406 // ALIGNS THE VEHICLE EAST WEST SOUTH NORTH BASED ON CURRENT ROTATION (PRESTAGE AND STAGE DURING DRAG MODE)
408 llSetRot( llEuler2Rot( <Rad.x, Rad.y, llRound( Rad.z / PI_BY_TWO ) * PI_BY_TWO > ) );
409 }
410
411 menu(key user,string title,list buttons)
412 {
413 llListenRemove(menu_handler);
414 menu_channel = (integer)(llFrand(99999.0) * -1);
415 menu_handler = llListen(menu_channel,"","","");
416 llDialog(user,title,buttons,menu_channel);
417 llSetTimerEvent(30.0);
418 }
419
420 showdata(string s){
421 llSetText(s+"\n.\n.\n.\n.",<1,1,.6>,1.0);
422 //llSetText("",<0,0,0>,1.0);
423 }
424
425 enginesound(){
426 vector vel = llGetVel();
427 float speed = llVecMag(vel);
428 if(speed <=20){
429 gNewSound = 0;
430 }
431 else if(speed >=50){
432 gNewSound = 2;
433 }
434 else {
435 gNewSound = 1;
436 }
437
438 if(gOldSound != gNewSound){
439 if(speed <=20){
440 llLoopSound(gSoundIdle,1.0);
441 }
442 else if(speed >=50){
443 llLoopSound(gSoundAggressive,1.0);
444 }
445 else {
446 llLoopSound(gSoundSlow,1.0);
447 }
448 gOldSound = gNewSound;
449 }
450 }
451
452 cornerFXR(){
453 vector vel = llGetVel();
454 float speed = llVecMag(vel);
455 if(speed >50){
456 llMessageLinked(LINK_SET, 0, "letsburnR", NULL_KEY);
457 }
458 }
459
460 cornerFXL(){
461 vector vel = llGetVel();
462 float speed = llVecMag(vel);
463 if(speed >50){
464 llMessageLinked(LINK_SET, 0, "letsburnL", NULL_KEY);
465 }
466 }
467
468 default {
470 {
471 init_engine();
472 state Ground;
473 }
474 }
475
476 state Ground{
477
479 }
480 on_rez(integer param) {
482 preload_sounds();
483 init_PhysEng();
484 }
485
486 changed(integer change){
487 if((change & CHANGED_LINK) == CHANGED_LINK){
488 gAgent = llAvatarOnSitTarget();
489 if(gAgent != NULL_KEY){
490 if( (gAgent != llGetOwner()) && (gDrivePermit == 1)){
491 llSay(0, gUrNotAllowedMessage);
492 llUnSit(gAgent);
493 llPlaySound(gSoundAlarm,1.0);
494 llPushObject(gAgent, <0,0,20>, ZERO_VECTOR, FALSE);
495 }
496 else {
498 gOldAgent = gAgent;
499 init_PhysEng();
500 set_engine();
502 gRun = 1;
503 }
504 }
505 else {
506 llSetStatus(STATUS_PHYSICS, FALSE); //SHOULD THIS BE THE LAST THING YOU SET??
507 gRun = 0;
508 init_engine();
509 llTriggerSound(gSoundStop,1);
510 llStopAnimation(gDrivingAnim);
511 llSetTimerEvent(0.0);
515 llSetText("",<0,0,0>,1.0);
516 }
517 }
518 }
520 if(perm) {
521 gGear = 2; // GEAR#0 IS STAGER | GEAR#1 IS BURNOUT | GEAR#2 IS THE FIRST GEAR (LIST INDEX STARTS @ 0)
522 //gNewGear = 2;
524 if(gCamFixed == 1) {
525 init_fixedCam(0);
526 }else{
527 init_followCam(0);
528 }
529 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
530 llMessageLinked(LINK_SET, 0, "headlight", "0");
531 llStartAnimation(gDrivingAnim);
532 llTriggerSound(gSoundStartup,1.0);
533 llSleep(1.5);
534 enginesound();
535 }
536 }
537
538 control(key id, integer held, integer change){
539 if(gRun == 0){
540 return;
541 }
542 integer reverse=1;
543 vector vel = llGetVel();
544 vector speedvec = llGetVel() / llGetRot();
545 gSpeed = llVecMag(vel);
546 gTurnRatio = llList2Float(gTurnRatioList,gGear);
547
548 if((held & change & CONTROL_UP) || ((gGear >= 11) && (held & CONTROL_UP))){
549 gGear=gGear+1;
550 if(gGear < 0) gGear = 0;
551 if(gGear > 11) gGear = 11;
552 gearshift(gGear);
553 }
554
555 if((held & change & CONTROL_DOWN) || ((gGear >= 11) && (held & CONTROL_DOWN))){
556 gGear=gGear-1;
557 if(gGear < 0) gGear = 0;
558 if(gGear > 11) gGear = 11;
559 gearshift(gGear);
560 }
561 if(held & CONTROL_FWD){
562 if(gGear == 0) {
564 }else{
566 }
567 if(gGear == 1) {
568 llMessageLinked(LINK_SET, 0, "letsburn", NULL_KEY);
569 llMessageLinked(LINK_SET, 0, "letsscreech", NULL_KEY);
570 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
571 }
572 if(gGear == 2) {
573 }
574 if(gGear == 3) {
575 }
576 if(gGear == 4) {
577 }
578 if(gGear == 5) {
579 }
580 if(gGear == 6) {
581 llMessageLinked(LINK_SET, 0, "pipeflame", NULL_KEY);
582 }
583 if(gGear == 7) {
584 }
585 if(gGear == 8) {
586 }
587 if(gGear == 9) {
588 }
589 if(gGear == 10) {
590 }
591 if(gGear == 11) {
592 }
593 powershift(gGear);
595 gMoving=1;
596 reverse=1;
597 gNewTireSpin = "ForwardSpin";
598
599 }
600
601 if(held & CONTROL_BACK){
605 gTurnRatio = -2.0;
606 reverse = -1;
607 gNewTireSpin = "BackwardSpin";
608 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
609 }
610 if(~held & change & CONTROL_FWD){
611 //llSay(0,"CONTROL_FWD:Released");
612 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
613 gNewTireSpin = "NoSpin";
614 gNewTurnAngle = "NoTurn";
615
616 if(gGear > 9){
617 gGear = 3;
618 }
619
620 }
621 if(~held & change & CONTROL_BACK){
622 //llSay(0,"CONTROL_BACK:Released");
623 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
624 gNewTireSpin = "NoSpin";
625 gNewTurnAngle = "NoTurn";
626 }
627 if(~held & ~change & CONTROL_FWD){
628 //llSay(0,"CONTROL_FWD:Inactive");
629 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
630 }
631 if(~held & ~change & CONTROL_BACK){
632 //llSay(0,"CONTROL_BACK:Inactive");
633 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
634 }
635
636 showdata("Speed Vector:" + (string)speedvec + " Speed:" + (string)(gSpeed*2.23692912) + " mph");
637 enginesound();
638
639 vector AngularMotor;
641 if(gGear==0){
642 AngularMotor.z -= gSpeed / ((gTurnRatio/gTurnMulti)*1);
643 }else{
644 AngularMotor.z -= gSpeed / ((gTurnRatio/gTurnMulti)*gGear);
645 }
646 gNewTurnAngle = "RightTurn";
647 gTurnCount = 10;
648 gTcountR = 2;
649 }
650
652 if(gGear==0){
653 AngularMotor.z += gSpeed / ((gTurnRatio/gTurnMulti)*1);
654 }else{
655 AngularMotor.z += gSpeed / ((gTurnRatio/gTurnMulti)*gGear);
656 }
657 gNewTurnAngle = "LeftTurn";
658 gTurnCount = 10;
659 gTcountL = 2;
660 }
661
663 if(gTcountL > 0){
664 gTcountL--;
665 //llSay(0,(string)gTcountL);
666 }
667 if(gTcountL == 1){
668 cornerFXL();
669 }
670 if(gTcountR > 0){
671 gTcountR--;
672 // llSay(0,(string)gTcountR);
673 }
674 if(gTcountR == 1){
675 cornerFXR();
676 }
677
678 if(gTurnCount > 0){
679 gTurnCount--;
680 }
681 if(gTurnCount == 1){
682 gNewTurnAngle = "NoTurn";
683 }
684 if(gTurnAngle != gNewTurnAngle){
685 gTurnAngle = gNewTurnAngle;
687 }
688 if(gTireSpin != gNewTireSpin){
689 gTireSpin = gNewTireSpin;
691 llMessageLinked(LINK_SET, 0, gTireSpin, NULL_KEY);
692 }
693
694 }
695
696 touch_start(integer total_number){
697 if(gAgent != NULL_KEY){
698 menu(llDetectedKey(0), "\nDriver's Menu.", MENU_MAIN);
699 }
700 }
701
702 listen(integer channel,string name,key id,string message){
703 if(channel == menu_channel){
704 llListenRemove(menu_handler);
706 if(message == "Align"){
707 llSay(0, "Car is lined up...");
708 nearestpi();
709 }
710 else if(message == "Hello"){
711 llSay(0, "Hello yourself");
712 }
713 // else if(message == "Button"){
714 // do something
715 //}
716 }
717 }
718
719
720 link_message(integer sender, integer num, string str, key id){
721
722 integer i = llGetLinkNumber() != 0; // Start at zero (single prim) or 1 (two or more prims)
723 integer x = llGetNumberOfPrims() + i; // [0, 1) or [1, llGetNumberOfPrims()]
724
725 for (; i < x; ++i)
726 {
727
728 if(llGetLinkName(i) == "spin")
729 {
730 rotation rootRot = llGetRootRotation();
731 vector rootPos = llGetRootPosition();
732
733 list params = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL,PRIM_SIZE]);
734 rotation childRot = llList2Rot(params,1);
735 vector childPos = (llList2Vector(params,0)-rootPos)/rootRot;
736 vector childSize = llList2Vector(params,2);
737
738 if(str == "ForwardSpin"){
739 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, TWO_PI, 1.0]);
740 }else if(str == "BackwardSpin"){
741 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,90.0,0.0>*DEG_TO_RAD*childRot, -TWO_PI, 1.0]);
742 }else if(str == "NoSpin"){
743 llSetLinkPrimitiveParamsFast(i, [PRIM_OMEGA, <0.0,00.0,0.0>*DEG_TO_RAD*childRot, 0, 1.0]);
744 }
745 }
746 }
747 }
748
749 timer(){
750 llListenRemove(menu_handler);
751 if(gRun == 1){
752
753 }else{
754 llSetTimerEvent(0.0);
755 }
756 }
757 }

Tour Airplane

Tour controller for airplane

Category: Tour Guide
By : Ferd Frederix
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2
3 // Revision:
4 // 0.1 8-17-2014 Initial Porting
5 // 0.2 8-22-2014 SL version
6 // 0.3 8-23-2014 Opensim Bulletsim
7
8 integer debug = TRUE;
9 integer LSLEDITOR = TRUE;
10
11 integer LINK_CMD = 0;
12 integer LINK_ANIMATE = 1;
13 integer LINK_POSITION = 2;
14 integer LINK_RL = 3;
15 integer LINK_UP = 4;
16 integer LINK_DOWN = 5;
17 integer LINK_SPEED = 6;
18
19 float PAUSE = 5; // PAUSE command time
20
21 float TIMER = 0.5;
22
23 integer MAX_TIME = 60;
24 integer running = FALSE;
25 integer ROGER = 1900; // channel we call for Roger with
26
27 string Route = "Route";
28 float MAX_DIST = 10.0; // how close to the target we have to be to consider it a successful trip.
29 integer lineNumber; // the line of the notecard we are using
30 integer nRoutes; // how many valid notecard locations there are
31 key kGetIndexLines; // the line we are reading from note card
32
33 list lLocations = [];
34 list lCommands= [];
35
36 integer timeout = 0; // if we cannot reach a spot, then move on
37 vector TargetLocation; // where we are headed, my be NULL_VECTOR
38
39
40 DEBUG(string msg) { if(debug) llSay(0,llGetScriptName() + ":" + msg); }
41
42 Init() {
43 lineNumber = 0;
44 llSensorRepeat("","",AGENT,20,PI,5);
46 }
47
48
49 default
50 {
51 on_rez(integer param)
52 {
53
54 }
55
57 {
58 lLocations = [];
59 lCommands = [];
60 lineNumber = 0;
61 kGetIndexLines = llGetNotecardLine(Route,lineNumber);
62 DEBUG("Reading Notecard");
63 }
64
65 dataserver(key queryid, string data)
66 {
67 if(queryid == kGetIndexLines)
68 {
69 if(data == EOF) {
70 state moving;
71
72 } else {
73 list lLine = (llParseString2List(data, ["|"], []));
74 string junk = llList2String(lLine, 0);
75 vector TempLocation = (vector) llList2String(lLine, 1);
76
77 lLocations += [TempLocation];
78 string TempDescription = llList2String(lLine, 2);
79 lCommands += [TempDescription];
80
81 lineNumber++;
82
83 kGetIndexLines = llGetNotecardLine(Route, lineNumber);
84 }
85 }
86 }
87
88
90 {
91 nRoutes = llGetListLength(lLocations);
92 lineNumber = 0;
93 llSetText("", <1,1,1>, 1.0);
94 TargetLocation = llList2Vector(lLocations, 0);
95 DEBUG("Ready");
96 }
97 }
98
99 state moving
100 {
101
102 link_message(integer sender_number, integer number, string message, key id)
103 {
104 //DEBUG("N:" + (string) number + ":" + message);
105 }
106
107 on_rez(integer param)
108 {
109 Init();
110 }
111
113 {
114 Init();
115 }
116
118 {
119 if(! running) {
120 DEBUG("Someone is here");
121 llMessageLinked(LINK_THIS,LINK_CMD,"StartNPC","");
122 running ++;
123 }
124 }
125
126 no_sensor()
127 {
128 if(running)
129 {
130 DEBUG("Person Ejected!");
131 llMessageLinked(LINK_THIS,LINK_CMD,"StopNPC","");
132 running = FALSE;
133 }
134 }
135
136 changed(integer what)
137 {
138 if(what & CHANGED_LINK)
139 {
140 key avatarKey = llAvatarOnSitTarget();
141 if(avatarKey != NULL_KEY)
142 {
143 llMessageLinked(LINK_THIS,0,"Seated","");
144
146 llSetTimerEvent(TIMER);
147
148 } else {
149 llSay(0,"Please stay seated, click the airplane!");
150 }
151 } else if(what & CHANGED_INVENTORY) {
153 }
154
155 }
156
157
158 timer()
159 {
160
161 DEBUG("Goto:" + (string) TargetLocation);
162 vector myPos = llGetPos();
163
164
165 if(LSLEDITOR)
166 myPos = TargetLocation;
167
168 if(llVecDist(myPos, TargetLocation) > MAX_DIST && TargetLocation != ZERO_VECTOR)
169 {
170 if(timeout++ > MAX_TIME) // Time Out to contingency
171 {
172 timeout = 0;
173 DEBUG("New Target");
174 TargetLocation = llList2Vector(lLocations, lineNumber);
175 lineNumber++;
176
177 llMessageLinked(LINK_THIS,2,(string) TargetLocation,"");
178
179 if(lineNumber > nRoutes)
180 {
181 state end;
182 }
183 }
184
185 } else {
186
187 DEBUG("Line Number:" + (string)lineNumber );
188
189
190 string Command = llList2String(lCommands,lineNumber);
191
192 if(Command == "cPause")
193 {
194 DEBUG("Roger Called");
195 llShout(ROGER,"Roger"); // Call for Roger
197 llSleep(PAUSE);
198 }
199
200
201 if(llStringLength(Command)) {
202 DEBUG("Cmd: " + (string) Command);
203 llMessageLinked(LINK_THIS,LINK_CMD,Command,"");
204 }
205
206 timeout = 0;
207
208 TargetLocation = llList2Vector(lLocations, lineNumber);
209 lineNumber++;
210
211 if(lineNumber > nRoutes)
212 {
213 if(!debug)
214 llDie();
216
217 }
218
219 DEBUG("*************** FlyTo: " + (string) TargetLocation);
220 llMessageLinked(LINK_THIS,LINK_POSITION,(string) TargetLocation,"");
221 }
222 }
223 }

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