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 Boat_lsl_for_opensim  

Boat_lsl_for_opensim

added a listener on ch 8000 to message back the boat's position.
added "up" and "down" flight commands processing to straighten boat.
added "touch" processing to straighten boat.
fixed llsit targets for opensim prim sitting

Category: Vehicles
By : Jules
Created: 2010-09-12 Edited: 2010-09-12
Worlds: Second Life

the Zip file

Download all files for Boat_lsl_for_opensim
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Boat_lsl_for_opensim_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 // additional fixes for opensim by Renmiri Writer @ Second Life on 9/12/2010
16
17 float forward_power = 25; //Power used to go forward (1 to 30)
18 float reverse_power = -15; //Power ued to go reverse (-1 to -30)
19 float turning_ratio = 5.0; //How sharply the vehicle turns. Less is more sharply. (.1 to 10)
20 string sit_message = "Ride"; //Sit message
21 vector green = <0,1,0>;
22 string not_owner_message = "You are not the owner of this vehicle ..."; //Not owner message
23
24 //Anything past this point should only be modfied if you know what you are doing
25
26 default
27 {
29 {
30 llSetSitText(sit_message);
31 llListen(8000, "","", "" );
32 // forward-back,left-right,updown
33 llSitTarget(<0.25,0,0.25>, ZERO_ROTATION );
34 llSetText(".message ch 8000 to find me. \n use Pageup, Pagedown if you get stuck \n touch me to straighten the boat",green,1.0);
35
36 llSetCameraEyeOffset(<-12, 0.0, 5.0>);
37 llSetCameraAtOffset(<1.0, 0.0, 2.0>);
38
39 llPreloadSound("boat_start");
40 llPreloadSound("boat_run");
46
47
48
50 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1);
52
54 llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 5 );
69 }
70
71 changed(integer change)
72 {
73 if(change & CHANGED_LINK)
74 {
75 key agent = llAvatarOnSitTarget();
76
77 if(agent)
78 {
79 if(agent != llGetOwner())
80 {
81 llSay(0, not_owner_message);
82 llUnSit(agent);
83 llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE);
84 }
85 else
86 {
87 llTriggerSound("boat_start",1);
88
89
91 llSleep(.4);
93 llSleep(.1);
95
96 llLoopSound("boat_run",1);
97 }
98 }
99 else
100 {
102
104 llSleep(.1);
106 llSleep(.4);
108 llTargetOmega(<0,0,0>,PI,0);
109
111 }
112 }
113
114 }
115
117 {
118 if(perm)
119 {
122 }
123 }
124
125 control(key id, integer level, integer edge)
126 {
127 integer reverse=1;
128 vector angular_motor;
129
130 //get current speed
131 vector vel = llGetVel();
132 float speed = llVecMag(vel);
133
134 //car controls
135 if(level & CONTROL_FWD)
136 {
138 reverse=1;
139 }
140 if(level & CONTROL_BACK)
141 {
143 reverse = -1;
144 }
145
147 {
148 angular_motor.z -= speed / turning_ratio * reverse;
149 angular_motor.x += 15;
150 }
151
153 {
154 angular_motor.z += speed / turning_ratio * reverse;
155 angular_motor.x -= 15;
156 }
157
158 if(level & (CONTROL_UP|CONTROL_DOWN))
159 {
160 if(level & (CONTROL_UP))
161 llSay(0,"UP");
162 if(level & (CONTROL_DOWN))
163 llSay(0,"DOWN");
164 vector position = llGetPos();
165 llSay(0, (string)position);
166 vector vRadBase = llRot2Euler( llGetRot() );
167 //-- round the z-axis to the nearest 90deg (PI_BY_TWO = 90deg in radians)
168 llSetRot( llEuler2Rot( <0.0, 0.0, llRound( vRadBase.z / PI_BY_TWO ) * PI_BY_TWO > ) );
169 }
170
172
173 } //end control
174 listen( integer channel, string name, key id, string message )
175 {
176
177 integer c = llStringLength(message);
178 vector position = llGetPos();
179 string newmessage = "" ;
180 llSay(0,"messsage "+message+" heard by boat at "+ (string)position);
181 } //end listen
182 touch_start( integer vIntTouches )
183 {
184 //-- convert our rotation to x/y/z radians
185 vector vRadBase = llRot2Euler( llGetRot() );
186 //-- round the z-axis to the nearest 90deg (PI_BY_TWO = 90deg in radians)
187 llSetRot( llEuler2Rot( <0.0, 0.0, llRound( vRadBase.z / PI_BY_TWO ) * PI_BY_TWO > ) );
188 } //end touch
189
190
191 } //end default
192
193
194 // Look for updates at : http://www.free-lsl-scripts.com/freescripts.plx?ID=1511
195 // __END__

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