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
Building control  

control

control.lsl

Category: Building
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for control
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. control_1.lsl
1
2 // MultiMove Controller Script
3
4 //
5
6 // Manages pilot seat and movement for the whole set
7
8
9
10 integer unichan = -28091988; // this is the channel used by the controller and
11
12 // objects to sync and move
13
14
15
16 float deltat = 0.125; // interval between updates
17
18
19
20 integer controlstaken; // control keys taken by the script, initialised later
21
22
23
24 integer listener;
25
26 integer maxl = 4;
27
28
29
30 vector sitoffset = <0.2,0,-0.2>; // sitting position
31
32 vector camoffset = <-24,0,9>; // camera position
33
34 vector camtarget = <12,0,0>; // camera direction
35
36 float speed = 1.0; // distance to move within deltat
37
38 float vspeed = 0.5; // vertical distance to move within deltat
39
40 integer rspeed = 3; // angle in degrees to rotate left or right within deltat
41
42
43
44 integer azimut; // direction in degrees around the Z axis (vertical)
45
46
47
48 default
49
50 {
51
53
54 {
55
57
58 }
59
60
61
63
64 {
65
66 llMinEventDelay(deltat);
67
68 llSitTarget(sitoffset, ZERO_ROTATION);
69
70 llSetCameraAtOffset(camtarget);
71
72 llSetCameraEyeOffset(camoffset);
73
75
76 }
77
78
79
81
82 {
83
84 if(c & CHANGED_LINK)
85
86 {
87
89
90 if(id != NULL_KEY)
91
92 {
93
94 if(id == llGetOwner())
95
96 {
97
99
100 } else llUnSit(id);
101
102 } else {
103
105
106 }
107
108 }
109
110 }
111
112
113
115
116 {
117
119
120 {
121
122 integer n;
123
124 for (n=0; n<maxl; ++n)
125
126 llShout(unichan + n, (string)(llGetRootPosition() + llGetRegionCorner()) + "*" + (string)azimut);
127
128
129 llSleep(1.0);
130
131 llTakeControls(controlstaken, TRUE, FALSE);
132
133 } else {
134
136
137 llShout(unichan, (string)llGetRootPosition() + "*" + (string)azimut);
138
139 }
140
141 }
142
143
144
145 control(key id, integer pressed, integer change)
146
147 {
148
150
151 rotation rtarget = llGetRootRotation();
152
153
154
156
157 {
158
159 // turning left
160
161 azimut = (azimut + rspeed) % 360;
162
163 rtarget *= llEuler2Rot(<0,0,DEG_TO_RAD * (float)rspeed>);
164
166
167 {
168
169 // turning right
170
171 azimut = (azimut - rspeed) % 360;
172
173 rtarget *= llEuler2Rot(<0,0,-DEG_TO_RAD * (float)rspeed>);
174
175 }
176
177
178
179 if(pressed & CONTROL_FWD)
180
181 {
182
183 // going forward
184
185 target += speed * llRot2Fwd(rtarget);
186
187
188
189 } else if(pressed & CONTROL_BACK)
190
191 {
192
193 // going backward
194
195 target += -speed * llRot2Fwd(rtarget);
196
197 }
198
199
200
201 if(pressed & CONTROL_UP)
202
203 {
204
205 // going forward
206
207 target += vspeed * llRot2Up(rtarget);
208
209
210
211 } else if(pressed & CONTROL_DOWN)
212
213 {
214
215 // going backward
216
217 target += -vspeed * llRot2Up(rtarget);
218
219 }
220
221
222
223 if(pressed | change)
224
225 {
226
227 listener = (listener + 1) % maxl;
228
229 llShout(unichan + listener, (string)target + "*" + (string)azimut);
230
231 }
232
233 }
234
235 }// END //

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