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
AO Basic_NPC_AO_Animation_Override  

Basic_NPC_AO_Animation_Override

The intent is to provide an efficient wa...

Category: AO
By : DZ
Created: 2013-09-06 Edited: 2013-08-02
Worlds: Second Life

the Zip file

Download all files for Basic_NPC_AO_Animation_Override
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Basic_NPC_AO_Animation_Override_1.lsl
1
2 // A basic OpenSimulator Walk and Stand animation override
3 // All Modifications are Copyright 2010 by Doug Osborn.
4
5 // This script is Licensed under the Creative Commons Attribution-Share Alike 3.0 License
6 // For a copy of the license terms please see http://creativecommons.org/licenses/by-sa/3.0
7
8 // This work uses content from the Second Life® Wiki article llGetAnimation. (http://wiki.secondlife.com/wiki/LlGetAnimation)
9 // Copyright © 2007-2009 Linden Research, Inc. Licensed under the Creative Commons Attribution-Share Alike 3.0 License
10
11 // This AO is optimized for OpenSimulator and DOES NOT POLL the animation list multiple times a second
12 // It relies instead on the CHANGED ANIMATION event. The timer is ONLY active when your avatar is swapping between stands.
13
14 // It is NOT optimized code. Yes it could be smaller and probably faster. This is simple, and is intended to provide a working object
15 // instead of a lasting tribute to anyones programming prowess. Feel free to Optimize and re-distribute to your hearts content.
16
17 // To use: Place this script in an object that will be attached to your avatar
18 // Place the animations in the same prim
19 // Change the CUSTOMIZATION section to reflect the names of YOUR animations.
20 // Attach to your avatar or a HUD position
21
22 // To Reset Detach and re-attach the object or Edit the object and Reset the script
23
24 // All of the overrides available via the traditional ZHAO can be controlled via this script.
25 // The following Animation Types can be used by expanding the StartAnimation function to include the animation type
26 //
27 // [ Standing ]
28 // [ Walking ]
29 // [ Sitting ]
30 // [ Sitting On Ground ]
31 // [ Crouching ]
32 // [ Crouch Walking ]
33 // [ Landing ]
34 // [ Standing Up ]
35 // [ Falling ]
36 // [ Flying Down ]
37 // [ Flying Up ]
38 // [ Flying ]
39 // [ Flying Slow ]
40 // [ Hovering ]
41 // [ Jumping ]
42 // [ Pre Jumping ]
43 // [ Running ]
44 // [ Turning Right ]
45 // [ Turning Left ]
46 // [ Floating ]
47 // [ Swimming Forward ]
48 // [ Swimming Up ]
49 // [ Swimming Down ]
50
51 // ************************** Customize YOUR AO by changing the names of the Animations, and the cycle time for your stands here.
52
53 // Change the folling lines to reflect the animation names you want to use
54
55 list StandNames = ["ao-sweetness-stand1", "ao-sweetness-stand2", "ao-sweetness-stand3", "ao-sweetness-stand4", "ao-sweetness-stand5"];
56
57 integer StandTime = 12; // change this number to the number of seconds between stands
58
59 string WalkAnimation = "sweetness walk"; // Change this string to the name of the Walk animation you want to use
60
61 string RunAnimation = "AO-Run-Female"; // Change this string to the name of the Run animation you want to use
62
63 string SitAnimation = "sweetness-sit-1"; // Change this string to the name of the sit animation you want to use
64 // For NPC AO, it is best to leave this blank. Expect SIT objects to provide the proper animation
65
66 string CrouchAnimation = "AO-Crouch-Female"; // Change this string to the name of the crouch animation you want to use
67
68 string FlyAnimation = "sweetness-fly-1"; // Change this string to the name of the fly animation you want to use
69
70 string HoverAnimation = "sweetness-hover4"; // Change this string to the name of the hover animation you want to use
71
72 string SoftLandAnimation = "AO-Softland1-Female"; // Change this string to the name of the softland animation you want to use
73
74 integer LandingTime = 3; // Change this to reflect the length of the standing animation in seconds.
75
76 string JumpAnimation = "AO-JumpFlip1-Female"; // Change this string to the name of the Jump animation you want to use
77
78 // *******************************************************************************************************************************
79
80 // ***** Below there be dragons <wink> not really! *******
81
82 // You should not need to change anything below these lines
83 // You are welcome to. If you break it, you get to keep all the parts!
84 //
85
86 key Owner; // the wearer's key
87
88 string LastAnimation = ""; // last llGetAnimation value seen
89
90 string LastAnimName = "";
91
92 string newAnimation = "";
93
94 float StandCount = 0.0;
95
96 integer PowerStatus = 1;
97
98 vector onColor = <42,255,42>; // all nice and green
99
100 vector offColor = <128,128,128>; // and grey
101
102 // User functions
103
104 Initialize(key id)
105 {
106 if(id == NULL_KEY) // detaching
107 {
108 llSetTimerEvent(0.0); // stop the timer
109 }
110 else // attached, or reset while worn
111 {
113 Owner = id;
114 StandCount = (float) llGetListLength(StandNames);
115 }
116 }
117
118 OnOff()
119 {
120 vector color;
121
122 if(PowerStatus == 0)
123 {
124 PowerStatus = 1;
125 newAnimation = llGetAnimation(Owner);
126 StartAnimation();
127 llOwnerSay("Over-ride active");
128 color = onColor;
129 }
130 else
131 {
132 PowerStatus = 0;
133 llStopAnimation(LastAnimName);
134 llOwnerSay("Over-ride off");
135 color = offColor;
136 }
137
138 llSetColor(color/255.0, ALL_SIDES);
139 }
140
141 StartAnimation()
142 {
143 if(LastAnimation != newAnimation)
144 {
145 if(newAnimation == "Walking")
146 {
147 llStopAnimation(LastAnimName);
148
149 if(WalkAnimation != "")
150 {
151 LastAnimName = WalkAnimation;
152
153 llStartAnimation(LastAnimName);
154 }
155
157 }
158
159 if(newAnimation == "Running")
160 {
161 llStopAnimation(LastAnimName);
162
163 if(RunAnimation != "")
164 {
165 LastAnimName = RunAnimation;
166
167 llStartAnimation(LastAnimName);
168 }
169
171
172 }
173
174 if(newAnimation == "Standing")
175 {
176 llStopAnimation(LastAnimName);
177
178 if(StandCount > 0.0)
179 {
180
181 integer whichone = (integer)llFrand(StandCount);// pick a new stand
182
183 LastAnimName = llList2String(StandNames,whichone);
184
185 llStartAnimation(LastAnimName);
186
187 if(StandCount > 1.0)
188 llSetTimerEvent(StandTime);
189 }
190 else
191 {
193 }
194 }
195
196 if(newAnimation == "Sitting")
197 {
198 llStopAnimation(LastAnimName);
199
200 if(SitAnimation != "")
201 {
202 LastAnimName = SitAnimation;
203
204 llStartAnimation(LastAnimName);
205 }
206
208 }
209
210 if(newAnimation == "Flying")
211 {
212 llStopAnimation(LastAnimName);
213
214 if(FlyAnimation != "")
215 {
216 LastAnimName = FlyAnimation;
217
218 llStartAnimation(LastAnimName);
219 }
220
222
223 }
224
225 if(newAnimation == "Hovering")
226 {
227 llStopAnimation(LastAnimName);
228
229 if(HoverAnimation != "")
230 {
231 LastAnimName = HoverAnimation;
232
233 llStartAnimation(LastAnimName);
234 }
235
237
238 }
239
240 if(newAnimation == "Soft Landing")
241 {
242 llStopAnimation(LastAnimName);
243
244 if(SoftLandAnimation != "")
245 {
246 LastAnimName = SoftLandAnimation;
247
248 llStartAnimation(LastAnimName);
249
250 llSetTimerEvent(LandingTime);
251 }
252
254
255 }
256
257 if(newAnimation == "Crouching")
258 {
259 llStopAnimation(LastAnimName);
260
261 if(CrouchAnimation != "")
262 {
263 LastAnimName = CrouchAnimation;
264
265 llStartAnimation(LastAnimName);
266 }
267
269
270 }
271
272 if(newAnimation == "Jumping")
273 {
274 llStopAnimation(LastAnimName);
275
276 if(JumpAnimation != "")
277 {
278 LastAnimName = JumpAnimation;
279
280 llStartAnimation(LastAnimName);
281 }
282
284
285 }
286 }
287 }
288
289
290 // Event handlers
291
292 default
293 {
295 {
296 // script was reset while already attached
297 if(llGetAttached() != 0) {
298 Initialize(llGetOwner());
299 }
300 }
301
302 attach(key id) {
303 Initialize(id);
304 }
305
307 {
309 llOwnerSay("Over-ride active");
310 }
311 }
312
313 touch_start(integer whodunit)
314 {
315 OnOff();
316 }
317
318 timer()
319 {
320 llStopAnimation(LastAnimName);
321
322 integer whichone = (integer)llFrand(StandCount); // pick the new stand at random
323
324 LastAnimName = llList2String(StandNames,whichone);
325
326 llStartAnimation(LastAnimName);
327
328 // llOwnerSay( "using " + LastAnimName); // uncomment this to see which stand gets trigger by the timer
329
330 llSetTimerEvent(StandTime);
331 }
332
333 changed (integer change)
334 {
335 if(change & CHANGED_ANIMATION)
336 {
337
338 newAnimation = llGetAnimation(Owner);
339
340 StartAnimation();
341
342 LastAnimation = newAnimation; // so we can check for changes
343
344 // llOwnerSay("started " + newAnimation); // uncomment this to see the event types you can respond to
345
346 // llOwnerSay( "using " + LastAnimName); // uncomment this to see which animations are being used
347
348
349 }
350 }
351 }

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