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
driving Horse_Riding_script  

Horse_Riding_script

put this script in the master prim(yellow) off the horse en drive

Category: driving
By : fratserke
Created: 2010-11-09 Edited: 2010-11-09
Worlds: Second Life

the Zip file

Download all files for Horse_Riding_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Horse_Riding_script_1.lsl
1 // History
2 // 0.5 added DustIsOn Boolean for streamlining
3 // 0.4 unknown
4 // 0.3 duston/dustoff split & anti-push global on/off
5 // 0.2 dust call & anti-push
6 // 0.1 fix attach event problem for attach from inventory
7 // 0.0 create
8
9 // globals
10 // animation to play when attached
11 string animation = "badhorseriding";
12
13 // this set to true will enable the "anti push" code so acts as a minimal push shield
14 integer anti_push = TRUE;
15
16 // time to wait if avatar does not move to "lock" into place.
17 // ignore if anti_push is false.
18 float lockwait = 1.0;
19
20 // globals for state tracking
21 integer have_permissions = FALSE;
22 integer is_attached = FALSE;
23 integer is_locked = FALSE;
24
25 // globals for boolean lists
26 integer perm_list;
27 integer control_list;
28
29 //integer clipclop;
30 integer effectFlags=0;
31 //integer running=1;
32 integer dustIsOn = FALSE;
33
34 // Color Secelection Variables
35
36 // Interpolate between startColor and endColor
37 integer colorInterpolation = 1;
38 // Starting color for each particle
39 vector startColor = <.85,.75,.72>;
40 // Ending color for each particle
41 vector endColor = <.85,.75,.72>;
42 // Starting Transparency for each particle (1.0 is solid)
43 float startAlpha = .5;
44 // Ending Transparency for each particle (0.0 is invisible)
45 float endAlpha = 0;
46 // Enables Absolute color (true) ambient lighting (false)
47 integer glowEffect = 0;
48
49
50 // Size & Shape Selection Variables
51
52 // Interpolate between startSize and endSize
53 integer sizeInterpolation = 1;
54 // Starting size of each particle
55 vector startSize = <.75,.75,0>;
56 // Ending size of each particle
57 vector endSize = <4,4,0>;
58 // Turns particles to face their movement direction
59 integer followVelocity = 0;
60 // Texture the particles will use ("" for default)
61 string texture = "smoke";
62
63
64 // Timing & Creation Variables Variables
65
66 // Lifetime of one particle (seconds)
67 float particleLife = 10;
68 // Lifetime of the system 0.0 for no time out (seconds)
69 float SystemLife = 0;
70 // Number of seconds between particle emissions
71 float emissionRate = .1;
72 // Number of particles to releast on each emission
73 integer partPerEmission = 5;
74
75
76 // Angular Variables
77
78 // The radius used to spawn angular particle patterns
79 float radius = 0;
80 // Inside angle for angular particle patterns
81 float innerAngle = 0;
82 // Outside angle for angular particle patterns
83 float outerAngle = 2;
84 // Rotational potential of the inner/outer angle
85 vector omega = <0,0,0>;
86
87
88 // Movement & Speed Variables
89
90 // The minimum speed a particle will be moving on creation
91 float minSpeed = 0;
92 // The maximum speed a particle will be moving on creation
93 float maxSpeed = .5;
94 // Global acceleration applied to all particles
95 vector acceleration = <0,0,0>;
96 // If true, particles will be blown by the current wind
97 integer windEffect = 1;
98 // if true, particles 'bounce' off of the object's Z height
99 integer bounceEffect = 0;
100 // If true, particles spawn at the container object center
101 integer followSource = 0;
102 // If true, particles will move to expire at the target
103 //integer followTarget = 1;
104 // Desired target for the particles (any valid object/av key)
105 // target Needs to be set at runtime
106 key target = "";
107
108
109 //As yet unimplemented particle system flags
110
111 integer randomAcceleration = 0;
112 integer randomVelocity = 0;
113 integer particleTrails = 0;
114
115 // Pattern Selection
116
117 // Uncomment the pattern call you would like to use
118 // Drop parcles at the container objects' center
119 //integer pattern = PSYS_SRC_PATTERN_DROP;
120 // Burst pattern originating at objects' center
121 //integer pattern = PSYS_SRC_PATTERN_EXPLODE;
122 // Uses 2D angle between innerAngle and outerAngle
123 integer pattern = PSYS_SRC_PATTERN_ANGLE;
124 // Uses 3D cone spread between innerAngle and outerAngle
125 //integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
126 //
127 //integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY;
128
129 setParticles()
130 {
131 // Here is where to set the current target
132 // llGetKey() targets this script's container object
133 // llGetOwner() targets the owner of this script
134 // Feel free to insert any other valid key
135 target="";
136 // The following block of if statements is used to construct the mask
137 if(colorInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_COLOR_MASK;
138 if(sizeInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_SCALE_MASK;
139 if(windEffect) effectFlags = effectFlags|PSYS_PART_WIND_MASK;
140 if(bounceEffect) effectFlags = effectFlags|PSYS_PART_BOUNCE_MASK;
141 if(followSource) effectFlags = effectFlags|PSYS_PART_FOLLOW_SRC_MASK;
142 if(followVelocity) effectFlags = effectFlags|PSYS_PART_FOLLOW_VELOCITY_MASK;
143 if(target!="") effectFlags = effectFlags|PSYS_PART_TARGET_POS_MASK;
144 if(glowEffect) effectFlags = effectFlags|PSYS_PART_EMISSIVE_MASK;
145 //Uncomment the following selections once they've been implemented
146 // if(randomAcceleration) effectFlags = effectFlags|PSYS_PART_RANDOM_ACCEL_MASK;
147 // if(randomVelocity) effectFlags = effectFlags|PSYS_PART_RANDOM_VEL_MASK;
148 // if(particleTrails) effectFlags = effectFlags|PSYS_PART_TRAIL_MASK;
150 PSYS_PART_FLAGS, effectFlags,
151 PSYS_SRC_PATTERN, pattern,
152 PSYS_PART_START_COLOR, startColor,
153 PSYS_PART_END_COLOR, endColor,
154 PSYS_PART_START_ALPHA, startAlpha,
155 PSYS_PART_END_ALPHA, endAlpha,
156 PSYS_PART_START_SCALE, startSize,
157 PSYS_PART_END_SCALE, endSize,
158 PSYS_PART_MAX_AGE, particleLife,
159 PSYS_SRC_ACCEL, acceleration,
160 PSYS_SRC_TEXTURE, texture,
161 PSYS_SRC_BURST_RATE, emissionRate,
162 PSYS_SRC_INNERANGLE, innerAngle,
163 PSYS_SRC_OUTERANGLE, outerAngle,
164 PSYS_SRC_BURST_PART_COUNT, partPerEmission,
167 PSYS_SRC_BURST_SPEED_MAX, maxSpeed,
168 PSYS_SRC_MAX_AGE, SystemLife,
169 PSYS_SRC_TARGET_KEY, target,
170 PSYS_SRC_OMEGA, omega ]);
171 }
172
173
174 // sample dust functions
175 duststart(integer is_running) {
176 // call dust particles
177 if(is_running) {
178 // agent is running
179 llLoopSound("98dc028e-c44b-b17d-4540-c0a7ba026908", 1);
180 setParticles();
181 dustIsOn = TRUE;
182 } else {
183 llLoopSound("e8a669ca-2400-69e3-693f-f87dd18fa9cd", 1);
184 }
185 }
186
187 duststop() {
188 // stop dust particles
190 if(dustIsOn) {
192 dustIsOn = FALSE;
193 }
194 }
195
196
197 // My own attach event because of bug with attach from inventory not calling attach event
198 doattach(key attachedAgent) {
199 // process the attach event
200 if(attachedAgent != NULL_KEY) {
201 // we are attached to an agent so set the attached state
202 is_attached = TRUE;
203 // Request permission to do stuff from agent
204 if(!have_permissions) llRequestPermissions(llGetOwner(), perm_list );
205 } else {
206 // we are not attached so set the state
207 is_attached = FALSE;
208 // if we HAVE permissions then assume we were animating an avatar
209 // (the avatar just detached us for example)
210 if(have_permissions) {
211 // stop animating the avatar
212 llStopAnimation(animation);
213 // reliquinsh our permissions (fake but good for state)
214 have_permissions = FALSE;
215 }
216 // turn off the push stuff
217 llSetTimerEvent(0.0);
218 // stop damping movement
220 // turn off locking
221 is_locked = FALSE;
222 }
223 }
224
225 // the meat of the script
226 default {
227 on_rez(integer initparm) {
228 // reset the script
230 }
231
232 state_entry() {
233 // sit from original horse control box
234 llSitTarget(<0.3,0,0.6>, ZERO_ROTATION);
235
236 // set up the state tracking vars to their initial values
237 dustIsOn = FALSE;
238 have_permissions = FALSE;
239 is_attached = FALSE;
240 is_locked = FALSE;
242 control_list = (CONTROL_FWD|
250
251 // Fake the attached event because we are attached and attached didn't get called.
253 }
254 changed(integer change)
255 {
256 if(change & CHANGED_OWNER) // You'd better put the this changed() event when you use llGetOwner
257 { // by way of precaution.
259 }
260 }
261 run_time_permissions(integer permissions) {
262 // process the permissions requests
263 if(permissions == perm_list) {
264 // if we are attached then start the animation and attach to the
265 // correct point on avatar
266 if(is_attached) {
267 // start the animation
268 llStartAnimation(animation);
269 llTakeControls(control_list, TRUE, TRUE);
270 llTriggerSound("a2b85091-b0c8-f77e-2c85-d52624b3081c", 1.0);
271 }
272 // start the antipush timer if script calls for it
273 if(anti_push) llSetTimerEvent(1);
274 // let everything know we got the permissions we requested
275 have_permissions = TRUE;
276 }
277 }
278
279 control(key id, integer level, integer edge) {
280 // check anti_push state
281 if(anti_push) {
282 // if we are locked and this event (control) is called then avatar requested move
283 // so we have to unlock
284 if(is_locked) {
285 // undamp avatar
287 // set locked state to false
288 is_locked = FALSE;
289 }
290 // reset the timer
292 }
293
294 // check to see if the agent is running
295 integer running = llGetAnimation(llGetPermissionsKey()) == "Running";
296 integer landing = llGetAgentInfo(llGetPermissionsKey()) & AGENT_FLYING;
297 integer jumping = llGetAnimation(llGetPermissionsKey()) == "Jumping";
298
299 // now we capture the various controls for any "effects hooks"
300 if(level>0 && edge>0) {
301 // these get called because the just got pressed
302 // they get called once
303 if(level & CONTROL_FWD) {
304 // avatar is starting to go forwards
305 }
306 if(level & CONTROL_BACK) {
307 // avatar is starting to go backwards
308 }
310 // avatar is starting to go right
311 }
313 // avatar is starting to go left
314 }
315 if(level & CONTROL_UP) {
316 // avatar is starting to go up
317 }
318 if(level & CONTROL_DOWN) {
319 // avatar is starting to go down
320 }
321 }else if(level>0) {
322 // these get called because the key is down!
323 // they get called repeatedly
324 if(level & CONTROL_FWD) {
325 // avatar is going forwards
326 if(!landing & !jumping) duststart(running);
327 else duststop();
328 }
329 if(level & CONTROL_BACK) {
330 // avatar is going backwards
331 if(!landing & !jumping) duststart(running);
332 else duststop();
333 }
335 // avatar is going right
336 if(!landing & !jumping) duststart(running);
337 else duststop();
338 }
340 // avatar is going left
341 if(!landing & !jumping) duststart(running);
342 else duststop();
343 }
344 if(level & CONTROL_UP) {
345 // avatar is going up
346 duststop();
347 }
348 if(level & CONTROL_DOWN) {
349 // avatar is going down
350 duststop();
351 }
352 }else{
353 // called once when key is up
354 if(edge & CONTROL_FWD) {
355 // avatar stopped going forwards
356 duststop();
357 }
358 if(edge & CONTROL_BACK) {
359 // avatar stopped going backwards
360 duststop();
361 }
363 // avatar stopped going right
364 duststop();
365 }
367 // avatar stopped going left
368 duststop();
369 }
370 if(edge & CONTROL_UP) {
371 // avatar stopped going up
372 duststop();
373 }
374 if(edge & CONTROL_DOWN) {
375 // avatar stopped going down
376 duststop();
377 }
378 }
379 }
380
381 attach(key attachedAgent) {
382 // we got attached so call the attach function (we swapped this because
383 // of a linden script bug where the attach event didn't get called
384 // when attached from inventory
385 doattach(attachedAgent);
386 }
387
388 timer() {
389 // if we are handling anti_push
390 if(anti_push) {
391 // check if we are not already locked and we haven't moved since our wait
392 if((!is_locked) && (llGetTime() > lockwait)) {
393 // ok we aren't already locked and it's past the lock interval
394 // so damp movement on the avatar
396 // set the locked state to true
397 is_locked = TRUE;
398 }
399 }
400 }
401 }
402

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