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  

Boat

Boat

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

the Zip file

Download all files for Boat
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Boat_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 = 25; //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 = 5.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
21 //Anything past this point should only be modfied if you know what you are doing
22
23 default
24 {
26 {
27 llSetSitText(sit_message);
28 // forward-back,left-right,updown
29 llSitTarget(<0.2,0,0.45>, ZERO_ROTATION );
30
31 llSetCameraEyeOffset(<-12, 0.0, 5.0>);
32 llSetCameraAtOffset(<1.0, 0.0, 2.0>);
33
34 llPreloadSound("boat_start");
35 llPreloadSound("boat_run");
41
42
43
45 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1);
47
49 llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 5 );
64 }
65
66 changed(integer change)
67 {
68
69
70 if(change & CHANGED_LINK)
71 {
72
73 key agent = llAvatarOnSitTarget();
74 if(agent)
75 {
76 if(agent != llGetOwner())
77 {
78 llSay(0, not_owner_message);
79 llUnSit(agent);
80 llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE);
81 }
82 else
83 {
84 llTriggerSound("boat_start",1);
85
86
88 llSleep(.4);
90 llSleep(.1);
92
93 llLoopSound("boat_run",1);
94 }
95 }
96 else
97 {
99
101 llSleep(.1);
103 llSleep(.4);
105 llTargetOmega(<0,0,0>,PI,0);
106
108 }
109 }
110
111 }
112
114 {
115 if(perm)
116 {
119 }
120 }
121
122 control(key id, integer level, integer edge)
123 {
124 integer reverse=1;
125 vector angular_motor;
126
127 //get current speed
128 vector vel = llGetVel();
129 float speed = llVecMag(vel);
130
131 //car controls
132 if(level & CONTROL_FWD)
133 {
135 reverse=1;
136 }
137 if(level & CONTROL_BACK)
138 {
140 reverse = -1;
141 }
142
144 {
145 angular_motor.z -= speed / turning_ratio * reverse;
146 angular_motor.x += 15;
147 }
148
150 {
151 angular_motor.z += speed / turning_ratio * reverse;
152 angular_motor.x -= 15;
153 }
154
156
157 } //end control
158
159
160 } //end default

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