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
Parachute Parachute  

Parachute

Parachute

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

the Zip file

Download all files for Parachute
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Parachute_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 displayChute(float alpha)
16 {
17 llSetLinkPrimitiveParams(2,[PRIM_COLOR, ALL_SIDES,<1,1,1>, alpha ]);
18 llSetLinkPrimitiveParams(3,[PRIM_COLOR, ALL_SIDES,<1,1,1>, alpha ]);
19 llSetLinkPrimitiveParams(4,[PRIM_COLOR, ALL_SIDES,<1,1,1>, alpha ]);
20 llSetLinkPrimitiveParams(5,[PRIM_COLOR, ALL_SIDES,<1,1,1>, alpha ]);
21 llSetLinkPrimitiveParams(6,[PRIM_COLOR, ALL_SIDES,<1,1,1>, alpha ]);
22 }
23
24 integer calculateGroundDistance()
25 {
26 vector pos = llGetPos();
27 float ground = llGround(pos);
28 float distance = llRound(pos.z-ground);
29 return (integer)distance;
30 }
31
32 displayGroundDistance()
33 {
34 llSetText("Distance to Ground: " + (string)calculateGroundDistance(),<0,1,0>,1);
35 }
36
37
38
39 default
40 {
41 attach(key id)
42 {
43 if(id)
44 {
45 state attached;
46 }
47 }
48 }
49
50
51 state attached
52 {
54 {
55 displayChute(0);
58 llPreloadSound( "parachute" );
59
60 }
61
62 attach(key id)
63 {
64 if(id==NULL_KEY)
65 {
66 state default;
67 }
68 }
69
70 timer()
71 {
72 if( (llGetAgentInfo(llGetOwner()) & AGENT_IN_AIR) &&
73 !(llGetAgentInfo(llGetOwner()) & AGENT_FLYING) )
74 {
75 state falling;
76 }
77 displayGroundDistance();
78 }
79 }
80
81 state falling
82 {
84 {
86 }
87
88 timer()
89 {
90 integer dist = calculateGroundDistance();
91
92 if( (dist<150) && (dist>20) )
93 state deployed;
94 displayGroundDistance();
95 }
96
97 attach(key id)
98 {
99 if(id==NULL_KEY)
100 {
101 state default;
102 }
103 }
104 }
105
106 state deployed
107 {
109 {
110 llTriggerSound("parachute",1);
111 displayChute(1);
112 llSetTimerEvent(0.1);
113 llStopAnimation("falldown");
114 llStartAnimation("hover");
115 }
116
117 timer()
118 {
119 // on the ground
120 if( !(llGetAgentInfo(llGetOwner()) & AGENT_IN_AIR) &&
121 !(llGetAgentInfo(llGetOwner()) & AGENT_FLYING) )
122 {
123 llStopAnimation("hover");
124 state attached;
125 }
126
127 // started flying
128 if( llGetAgentInfo(llGetOwner()) & AGENT_FLYING)
129 {
130 llStopAnimation("hover");
131 state attached;
132 }
133
134 vector v = llGetVel();
135 if( v.z < -7 )
136 {
138 }
139
140 displayGroundDistance();
141 }
142
143 attach(key id)
144 {
145 if(id==NULL_KEY)
146 {
147 llStopAnimation("hover");
148 state default;
149 }
150 }
151 }

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