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
Animation Unlimited_storage_Prim_Animator  

Unlimited_storage_Prim_Animator

This is the main prim animator script. You also need the Store 0 script. An article on how to use this to make objects move is at http://metaverse.mitsi.com/Secondlife/Posts/Robin/

Category: Animation
By : Ferd Frederix
Created: 2011-09-07 Edited: 2011-09-07
Worlds: Second Life

the Zip file

Download all files for Unlimited_storage_Prim_Animator
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Unlimited_storage_Prim_Animator_1.lsl
Get file # 2. Unlimited_storage_Prim_Animator_2.lsl
Get file # 3. Unlimited_storage_Prim_Animator_3.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Prim Animator DB
2 // 06/20/2011
3 // Author Ferd Frederix
4 // Use with one or more copies of the script 'Store 0..Store 1.. Store N'
5 // Copyright 2011 Fred Beckhusen aka Ferd Frederix
6 //
7 // Licensed under the GNU Version3 license at http://www.gnu.org/copyleft/gpl.html
8 // This program and the STORE scipts it uses must be left Copy/Transfer/MOD
9 // Any items that use these scripts may have more restrictive permissions.
10
11 // for help and how to use, see "http://meteverse.mitsi.com/secondlife/Posts/Prim-Animator-DB
12
13 // Prim position root script
14 // Put this script in the root prim.
15 // touch the prim to start recording
16
17 // Record - store a new set of child prim positions
18 // Clear RAM - wipe out all recording in the prim. Leaves the database intact
19 // Pause - insert a 0.1 second pause
20 // Erase - Erases the Server data
21 // Load - Loads the data from the Server
22 // Publisgh - Saves the data to the database
23 // Recordings - Lists all recordings ( up to 16)
24 // Name - name a new recording
25 // Play All Plays back all recordings with a 1 second Pause.
26
27 // Publish - Saves to database
28 // Help - Get Web Help
29 // More - TBD
30
31 // configurable things
32
33
34
35
36 string MyName ; // The creator of the animation
37 string MyItemName; // a Name just for this unique item and any copies
38
39 integer debug = FALSE; // if set to TRUE, debug info appears
40
41 // Code follows - no need to edit below this line.
42 // remote db reading
43 key kHttpRequestID;
44
45
46 integer countLoaded = 0; // how many nanims have been loaded via HTTP
47
48 integer iPlayChannel = 1; // the playback channel, this is the channel you use in LinkMessages
49 integer countchannel= 2001; // how many have been saved
50 integer iDialogChannel ; // dialog boxes
51 integer iPrimCount ; // total number of prims
52 integer iWantNameFlag; // flag indicating we are waiting for a name to be chatted
53 integer imax; // total records in store
54 integer runtime = 0; // set to 1 after Recording and publishing.
55 // animation store
56 string sCurrentAnimationName; // The name of the animation we are playing
57 string sPriorAniName; // the prior animation name so we can spot differences as we read them in
58 list lLastPrimList; // storage of the last prim position we learned
59 integer iLastSTRIDE = 4; // size of the last prim list
60 integer iListenerHandle; // temp iListenerHandle when we are waiting for them to give us a name
61 list lUserAnimNames; // animations read from the notecard added to the Menu display
62
63
64 // Commands
65 integer Clear = 99; // erase local db
66 integer Erase = 100; // erase Server DB command
67 integer Add = 101; // add a coordinate
68 integer Publish = 102; // save to db
69 integer Name = 103; // send Name to db
70 integer thisName = 104; // send thisName to db
71 integer Play = 105; // play channel to make an animation run
72
73 Debug( string msg)
74 {
75 if(debug) llOwnerSay(msg);
76 }
77
78 // clear any old listeners and make a new on to control lag
79 NewListen()
80 {
81 iDialogChannel = (integer) (llFrand(400) + 300);
82 llListenRemove(iListenerHandle);
83 iListenerHandle = llListen(iDialogChannel,"","","");
84 }
85
86 // prompt the user for an animation name. Uses text box or chat
87 AskForName()
88 {
89 iWantNameFlag = TRUE;
91 NewListen();
92 llOwnerSay("Enter the name in the text box or type the new animation name on channel /" + (string) iDialogChannel );
93 llTextBox(llGetOwner(),"Type the new animation name",iDialogChannel);
94 }
95
96
97 Get(string data)
98 {
99 Debug("Data was " + data);
100
101 list lLine = (llParseString2List(data, ["|"], []));
102 string sAniName = llList2String(lLine,0);
103 string sNum = (string) Getline(lLine,1);
104 float fNum = (float) sNum;
105 vector vPos = (vector) Getline(lLine,2); // global for calcChild()
106 rotation rRot = (rotation) Getline(lLine,3); // global for calcChild()
107 vector vprimSize = (vector) Getline(lLine,4);
108 countLoaded++;
109 // the first record is always the root prim size
110 if(fNum == 0)
111 {
112 FetchNext();
113 return;
114 }
115
116 if(sAniName != sPriorAniName)
117 {
118 sPriorAniName = sAniName;
119 sCurrentAnimationName = sAniName;
120 if(llListFindList(lUserAnimNames,[sAniName]) == -1)
121 {
122 Debug("Loading animation " + sAniName);
123 lUserAnimNames += sAniName;
124 }
125
126 }
127 // Debug("Loading Prim #" + (string) fNum);
128 if(fNum != 1) // skip root prim
129 {
130 sCurrentAnimationName = sAniName;
131 llMessageLinked(LINK_THIS,Add,sAniName
132 +"|"
133 + (string) fNum
134 +"|"
135 + (string) vPos
136 + "|"
137 + (string) rRot
138 + "|"
139 + (string) vprimSize,"");
140
141
142
143 llSetText("Initialising... \n" + (string) (countLoaded) , <1,1,1>, 1.0);
144 }
145 llSleep(1); // http throttle avoidance
146
147 FetchNext();
148
149 }
150 // in case of hand editing, we wupe out extra stuff at end
151 string Getline(list Input, integer line)
152 {
153 return llStringTrim(llList2String(Input, line),STRING_TRIM);
154 }
155
156 Record()
157 {
158 if(llStringLength(sCurrentAnimationName) > 0)
159 {
160 integer ifoundmovement = 0; // will be set if any child moved
161 integer iPrimCounter ; // skip past the root prim
162 for (iPrimCounter =2; iPrimCounter <= iPrimCount ; iPrimCounter++ )
163 {
164 list my_list = llGetLinkPrimitiveParams(iPrimCounter,[PRIM_POSITION,PRIM_ROTATION, PRIM_SIZE ]);
165
166 // position is always in region coordinates, even if the prim is a child or the root prim of an attachment.
167 // rot is always the global rotation, even if the prim is a child or the root prim of an attachment.
168 // get current prim pos, rot and size
169
170 vector vrealPrimPos = llList2Vector(my_list,0) - llGetPos(); // position subtract Global Pos
171 vrealPrimPos /= llGetRot();
172 rotation rrealPrimRot = llList2Rot(my_list,1) / llGetRot(); // rotation subtract Global Rot
173 vector vrealPrimSize = llList2Vector(my_list,2); // size
174
175 // compare it to the last one we had, stride of list is a 4, and it is already sorted
176 integer iindex = (iPrimCounter - 2) * iLastSTRIDE; // zeroth position is fPrimCounter - start, or 2
177
178 // get the last thing we remembered about this prim
179 integer iprimNum = llList2Integer(lLastPrimList, iindex); // must be 0,1,2, in order
180 vector vlastPrimPos = llList2Vector(lLastPrimList, iindex+1);
181 rotation rlastPrimRot = llList2Rot(lLastPrimList, iindex+2);
182 vector vlastPrimSize = llList2Vector(lLastPrimList, iindex+3);
183
184 // if anything changed on this prim, we must record it.
185 if(vlastPrimPos != vrealPrimPos ||
186 rlastPrimRot != rrealPrimRot ||
187 vlastPrimSize!= vrealPrimSize
188 )
189 {
190 ifoundmovement++;
191
192 //Save them in the master list of all animations
193 llMessageLinked(LINK_THIS,Add,sCurrentAnimationName+ "|"
194 + (string) iPrimCounter
195 + "|"
196 + (string) vrealPrimPos
197 + "|"
198 + (string) rrealPrimRot
199 + "|"
200 + (string) vrealPrimSize,"");
201
202
203 imax = llGetListLength(lLastPrimList);
204 // save the changes in the last prim list so we can keep our lists smaller
205
206 lLastPrimList = llListReplaceList(lLastPrimList,[vrealPrimPos],iPrimCounter+1,iPrimCounter+1);
207 lLastPrimList = llListReplaceList(lLastPrimList,[rrealPrimRot],iPrimCounter+2,iPrimCounter+2);
208 lLastPrimList = llListReplaceList(lLastPrimList,[vrealPrimSize],iPrimCounter+3,iPrimCounter+3);
209 //Debug("Saved in history at prim # " + (string) (iPrimCounter));
210 llSleep(0.1);
211 } // if
212 else
213 {
214 Debug("Same @" + (string) iPrimCounter);
215 }
216
217 } // for
218
219 if(!ifoundmovement)
220 {
221 llOwnerSay("You must move at least one child prim.");
222 }
223
224 }
225 else
226 {
227 AskForName();
228 }
229
230 }
231
232 // on reset, record the base position in history so we can see changes
233
234 ClearRAM()
235 {
236
237 iPrimCount = llGetNumberOfPrims(); // how many we are recording
238 Debug("Prim Count = " + (string) iPrimCount);
239
240 sCurrentAnimationName = ""; // no name in use
241
242 lLastPrimList = []; // wipe last animations list
243 integer iPrimCounter ;
244 integer primCounter = 0;
245 for (iPrimCounter=2; iPrimCounter <= iPrimCount ; iPrimCounter++ ) // skip 1, which is the root prim
246 {
247 list my_list = llGetLinkPrimitiveParams(iPrimCounter,[PRIM_POSITION, PRIM_ROTATION, PRIM_SIZE ]);
248
249 // save the local pos and rot, since llGetLinkPrimitiveParams returns global pos and rot
250 vector primpos = llList2Vector(my_list,0) - llGetPos();
251 primpos /= llGetRot();
252 rotation primrot = llList2Rot(my_list,1) / llGetRot();
253
254 vector primsize = llList2Vector(my_list,2) ;
255 lLastPrimList += iPrimCounter;
256 lLastPrimList += primpos;
257 lLastPrimList += primrot;
258 lLastPrimList += primsize;
259 primCounter++;
260 }
261 llOwnerSay("RAM is cleared - Initial Settings saved for " + (string) primCounter + " child prims");
262 }
263
264
265 rotation calcChildRot(rotation rdeltaRot)
266 {
268 return rdeltaRot/llGetLocalRot();
269 else
270 return rdeltaRot/llGetRootRotation();
271 }
272
273
274 MakeMenu()
275 {
276 if(runtime)
277 {
278 MakeMenu2();
279 return;
280 }
281
282 list amenu = ["Name", "Record","Pause"] +
283 ["Erase","Load","Publish"] +
284 ["Recordings","-","Play All"] +
285 ["Help","-", "Finish"];
286
287 string menuText = "Available Memory: " + (string) llGetFreeMemory() +
288 "\n\n" +
289 "Recordings: Select a named animation\n" +
290 "Name: Set the animation name\n" +
291 "Play All: Play all animations\n" +
292 "Erase: Delete Recorded Data\n" +
293 "Load: Get from Server\n" +
294 "Publish: Save to Server\n" +
295 "Record: Record a snapshot of prim positions\n" +
296 "Pause: Insert 0.1 second pause\n" +
297 "Finish: End all programming\n" +
298 "Help: Help";
299
300 NewListen();
301 llDialog(llGetOwner(), menuText,amenu,iDialogChannel);
302
303 }
304
305 MakeMenu2()
306 {
307 string menuText ;
308 list menu2 = lUserAnimNames;
309 menu2 = llDeleteSubList(menu2,11,999); // 12 max
310
311 if(runtime)
312 menu2 += "Unlock";
313 if(llGetListLength(lUserAnimNames) == 0)
314 {
315 menu2 += ["Back"] ;
316 menuText = " There are no animation names to display\n\n" +
317 "Back:- Go back to programming menu";
318 }
319 else
320 menuText = "Pick an animation to play.";
321
322 NewListen();
323 llDialog(llGetOwner(), menuText,menu2,iDialogChannel);
324 }
325
326
327 FetchNext()
328 {
329 string url = "http://metaverse.mitsi.com/cgi/animate.plx?Type=Load&Count=" + (string) countLoaded + "&Name=" + llEscapeURL(MyName) + "&Password=" + llEscapeURL(MyItemName);
330 Debug(url);
331
332 kHttpRequestID = llHTTPRequest(url, [], "");
333 }
334
335
336 default
337 {
339 {
340 MyName = llKey2Name(llGetCreator()); // assign the creator if we get reset
341 MyItemName = llGetObjectName(); // and get the name of the Object
342 llOwnerSay("Animation name from the description is " + MyItemName);
343
344 if(MyItemName == "(No Description)" || llStringLength(MyItemName) == 0)
345 {
346 MyItemName = "Archipelis_" + (string) (llCeil(llFrand(200000) + 5000000)); // pick a large random number for a name
347 llOwnerSay("Animations will be saved as '" + MyItemName + "'");
348 llSetObjectDesc(MyItemName);
349 }
350
351
352 llMessageLinked(LINK_THIS,Name,MyName,"");
353 llMessageLinked(LINK_THIS,thisName,MyItemName,"");
354
355 if(runtime)
356 {
357 ClearRAM();
358 FetchNext(); // start with first line in DB
359 }
360 else
361 {
362 ClearRAM();
363 }
364 }
365
366 http_response(key queryid, integer status, list metadata, string data)
367 {
368 if(queryid == kHttpRequestID )
369 {
370 if(status == 200) // HTTP success status
371 {
372 if(data == "nothing to do")
373 {
374 llOwnerSay("Initialized with " + (string) countLoaded + " settings");
375 llSetText("" , <1,1,1>, 1.0);
376 return;
377 }
378 Get(data);
379 }
380 else
381 {
382 llOwnerSay("Server Error loading animations");
383 }
384 }
385 }
386
387 touch_start(integer total_number)
388 {
390 {
391 MakeMenu();
392 }
393 }
394
395 // timed out waitig for a name of an animation
396 timer()
397 {
398 iWantNameFlag = FALSE;
400 llOwnerSay(" Timeout waiting for animation name");
401 llListenRemove(iListenerHandle);
402 }
403
404 listen( integer channel, string name, key id, string message )
405 {
406 llListenRemove(iListenerHandle);
407 // Debug(message);
408
409 if(message == "Finish")
410 {
411 runtime++;
412 llOwnerSay("The animator is now locked. Further touches will bring up a list of animations. You must unlock the menu to add more animations");
413 }
414 else if(message == "Unlock")
415 {
416 runtime = 0;
417 llOwnerSay("The animator is now unlocked for programming.");
418 }
419
420 else if(message == "Erase")
421 {
422 ClearRAM();
423 llMessageLinked(LINK_THIS,Erase,"",""); // erase the db
424 MakeMenu();
425 }
426 else if(message =="Pause")
427 {
428 llMessageLinked(LINK_THIS,Add,"sCurrentAnimationName|"
429 + "-0.1" // sleep 1 tenth a second
430 + "|"
431 + "<0,0,0>" // null pos
432 + "<0,0,0,1>" // null rot
433 + "|"
434 + "<0,0,0>",""); // null size
435 MakeMenu();
436 }
437 else if(message == "Recordings")
438 {
439 MakeMenu2();
440 }
441 else if(message == "Load")
442 {
443 countLoaded = 0;
444 FetchNext(); // start with first line in DB
445 }
446 else if(message == "Record")
447 {
448 Record();
449 MakeMenu();
450 }
451 else if(message == "Publish")
452 {
453 llMessageLinked(LINK_THIS,Name,MyName,""); // in case we reset just the stores
454 llMessageLinked(LINK_THIS,thisName,MyItemName,"");
455 llMessageLinked(LINK_THIS,Publish,"","");
456 MakeMenu();
457 }
458 else if(message == "Name")
459 {
460 AskForName();
461 }
462 else if(message == "Back")
463 {
464 MakeMenu();
465 }
466 else if(message == "More")
467 {
468 MakeMenu();
469 }
470 else if(message == "Play All")
471 {
472 integer l = llGetListLength(lUserAnimNames);
473 if(l == 0)
474 llOwnerSay("Nothing to do");
475 else
476 {
477 integer i = 0;
478 for ( i = 0; i < l; i++)
479 {
480 string ani = llList2String(lUserAnimNames,i);
481 llMessageLinked(LINK_THIS,Play,ani,"");
482 llSleep(1);
483 }
484 }
485 MakeMenu();
486
487 }
488 else if(message == "Help")
489 {
490 llLoadURL(llGetOwner(),"View online help", "http://metaverse.mitsi.com/secondlife/Posts/Prim-Animator-DB");
491 }
492 else if(iWantNameFlag)
493 {
494 sCurrentAnimationName = message;
495 if(llGetListLength(lUserAnimNames) < 11)
496 {
497 if(llListFindList(lUserAnimNames,[sCurrentAnimationName]) == -1)
498 lUserAnimNames += message;
499 }
500 else
501 {
502 lUserAnimNames = llDeleteSubList(lUserAnimNames,11,99);
503 }
504
505 MakeMenu();
506
507 llOwnerSay("Ready to record animation '" + sCurrentAnimationName + "'");
508 llOwnerSay("Position all child prims, then select the Menu item 'Record', and repeat as necessary. When finished, click 'Recordings' to play back the animation. Click 'Name' again to start a new animation sequence.");
509
510 iWantNameFlag = 0;
512 }
513 else
514 {
515 if(llListFindList(lUserAnimNames,[message]) != -1)
516 {
517 Debug("playback animation " + message);
518 llMessageLinked(LINK_THIS,Play,message,"");
519 MakeMenu();
520 }
521 }
522 }
523
524 link_message(integer sender_num, integer num, string message, key id)
525 {
526 if(num == countchannel)
527 {
528 llSetText(message,<1,1,1>,1.0);
529 llSleep(1);
530 llSetText("",<1,1,1>,1.0);
531 }
532 else if(num == iPlayChannel) // external messages come in channel 1 - change them to channel Play
533 {
534 Debug("playback animation " + message);
535 llMessageLinked(LINK_THIS,Play,message,"");
536 }
537 }
538
539
540 }

Unlimited_storage_Prim_Animator

This script must be named 'Store 0'. Yeasch script saves about 200 prim animations when compiled into mono. You can add additional storage scripts by naming them sequentially Store 1, STore 2, and so on.

Category: Animation
By : Ferd Frederix
Created: 2011-09-07 Edited: 2011-09-07
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Prim Animator DB
2 // 06/20/2011
3 // Author Ferd Frederix
4
5 // Prim Storage script.
6 // Copyright 2011 Fred Beckhusen - all rights reserved
7
8
9 integer debug =FALSE;
10 // return codes
11 integer playchannel = 2000; // the script to do the actual playback
12 integer countchannel= 2001; // the script to do the actual playback
13
14 // constants
15 integer MAX = 999; // Maximum number of anims per script, if set to very high, oit clamps with free memory < 1000
16 integer full = FALSE; // this script RAM is full
17
18
19 // Commands
20 integer Erase = 100; // erase command
21 integer Add = 101; // add a coordinate
22 integer Publish = 102; // save to db
23 integer Name = 103; // send Name to db
24 integer Password = 104; // send Password to db
25 integer Play = 105; //
26
27 // vars
28 integer myNum = 0; // the number at the end of this script name 0, 1, 2....
29 integer imax; // total records in store
30 integer datum; // the load counter increments as we load anims from db
31 string MyName;
32 string MyPassword;
33
34
35 // remote db reading
36 key kHttpRequestID;
37
38 // lists
39 list names; // a list of distnct animation names stored here
40 list db; // name, prin num, pos, rot, size
41 integer STRIDE = 5; // 4 items in the above list
42 integer recordcount = 0; // how many anims are stored
43
44
45 vector vRootScale ; // the initial size when the prims were recorded
46 vector vScaleChange = <1,1,1>; // The change percent if resized
47
48 GetScale(vector orig_size)
49 {
50 //Debug ("Size:" + (string) orig_size);
51 vRootScale = orig_size; // save the size when we recorded the prims
52 vector newScale = llGetScale();
53 vScaleChange.x = newScale.x / vRootScale.x;
54 vScaleChange.y = newScale.y / vRootScale.y;
55 vScaleChange.z = newScale.z / vRootScale.z;
56
57 }
58
59
60 rotation calcChildRot(rotation rdeltaRot)
61 {
63 return rdeltaRot/llGetLocalRot();
64 else
65 return rdeltaRot/llGetRootRotation();
66 }
67 // Start saving records. The first record is the prim size.
68
69 StartPublishing ()
70 {
71 imax = llGetListLength(db);
72 datum = 0; // point to the first record, counts as we load records
73 integer howmany = imax / STRIDE ;
74 llOwnerSay((string) howmany + " movements recorded - now saving to server.");
75 string url;
76
77 // cannot save or delete unless we are the first prim to Publish
78 string save;
79 string erase = "0";
80 if(myNum == 0) {
81 erase = "1";
82 save = "Save";
83 }
84
85 //Debug( "Saving Size:" + (string) llGetScale());
86 url = "http://secondlife.mitsi.com/cgi/animate.plx?Type=";
87 url += save;
88 url += "&Name=" + llEscapeURL(MyName) + "&Password=" + llEscapeURL(MyPassword);
89 url += "&Delete=";
90 url += erase;
91 url += "&aniName=RootPosition" ;
92 url += "&PrimNum=" + (string) 0;
93 url += "&Size=" + (string) llGetScale(); // save the scale as the first record
94 url += "&Pos=<1,1,1>" ;
95 url += "&Rot=<0,0,0,1>" ;
96
97 Debug(url);
98 kHttpRequestID = llHTTPRequest(url, [], "");
99 }
100
101
102
103 Put()
104 {
105 if(datum < imax)
106 {
107 string sAniName = llList2String(db, datum);
108 float fprimNum = llList2Float(db, datum+1);
109 vector vprimPos = llList2Vector(db, datum+2);
110 rotation rprimRot = llList2Rot(db, datum+3) ;
111 vector vprimSize = llList2Vector(db, datum+4);
112
113 string url = "http://secondlife.mitsi.com/cgi/animate.plx?Type=Save&Name=" + llEscapeURL(MyName) + "&Password=" + llEscapeURL(MyPassword);
114 url += "&aniName=" + llEscapeURL(sAniName);
115 url += "&PrimNum=" + (string) fprimNum;
116 url += "&Pos=" + (string) vprimPos;
117 url += "&Rot=" + (string) rprimRot;
118 url += "&Size=" + (string) vprimSize;
119
120 Debug(url);
121 if((datum/STRIDE) % 10 == 0 && datum)
122 llMessageLinked(LINK_THIS,countchannel,"Saved " + (string) (datum/STRIDE) + " records","");
123
124
125 kHttpRequestID = llHTTPRequest(url, [], "");
126 llSleep(1);
127 datum += STRIDE;
128 }
129 else
130 {
131 llMessageLinked(LINK_THIS,countchannel,(string) (datum/STRIDE) + " movements saved.","");
132 llSleep(2.0);
133 llMessageLinked(LINK_THIS,countchannel,"","");
134 }
135
136 }
137
138
139 Debug(string msg)
140 {
141 if(debug)
142 llOwnerSay(llGetScriptName() + ":" + msg);
143 }
144
145
146 default
147 {
149 {
150 string name = llGetScriptName();
151 list parts = llParseString2List(name,[" "],[""]);
152 myNum = llList2Integer(parts,1);
153
154 vRootScale = llGetScale();
155 Add += 10 * myNum;
156 }
157
158 link_message(integer sender_num, integer num, string msg, key id)
159 {
160
161 Debug("cmd:" + (string) num + ":" + msg);
162
163 // valid commands only.
164 if(num != Erase && num != Play && num != Add && num != Publish && num != Name && num!= Password)
165 return;
166
167 Debug("cmd:" + (string) num + ":" + msg);
168
169
170 if(num == Erase)
171 {
172 db = [];
173 Debug((string) myNum + " erased " );
174 full = FALSE;
175 recordcount = 0;
176 return;
177 }
178 else if(num == Add)
179 {
180 if(full)
181 {
182 Debug((string) myNum + " pass Add on to " + (string) (num +10));
183 llMessageLinked(LINK_THIS,num +10,msg,id);
184 return;
185 }
186
187 //Debug("Add");
188 list vecs = llParseString2List(msg,["|"],[""]);
189
190 // Debug(llDumpList2String(vecs,"---"));
191 string name= llList2String(vecs,0);
192 if(llListFindList(names,[name]) == -1)
193 names += name;
194
195 float fNum = (float) (llList2String(vecs,1));
196 vector vPos = (vector) (llList2String(vecs,2));
197 rotation rRot = (rotation) (llList2String(vecs,3));
198 vector vprimSize = (vector) (llList2String(vecs,4));
199
200 db += name;
201 db += fNum;
202 db += vPos;
203 db += rRot;
204 db += vprimSize;
205
206 recordcount ++;
207 Debug("Store contains " + (string) recordcount + "Records");
208 //if(recordcount> MAX)
209 //{
210 // Debug("Full, record count = " + (string) recordcount);
211 // full++;
212 //}
213 if(llGetFreeMemory() < 1000)
214 {
215 Debug("Full");
216 full++;
217 }
218
219 Debug("Free:" + (string) llGetFreeMemory());
220 }
221 else if(num == Name)
222 {
223 MyName = msg;
224 }
225 else if(num == Password)
226 {
227 MyPassword = msg;
228 }
229 else if(num == Play)
230 {
231 if(llListFindList(names,[msg]) == -1)
232 {
233 Debug("Animation " + msg + " not found");
234 return;
235 }
236 integer currpos;
237 integer end = recordcount * STRIDE;
238 // play back all we find
239 for (currpos = 0; currpos < end; currpos+= STRIDE)
240 {
241 if( msg == llList2String(db,currpos) )
242 {
243 float fPrim = (float) llList2String(db,currpos+1);
244 vector vPos = (vector) llList2String(db,currpos+2);
245 rotation rRot = (rotation) llList2String(db,currpos+3);
246 vector vprimSize = (vector) llList2String(db,currpos+4);
247
248 //Debug(msg + "|" + spos + "|" + srot + "|" + sthesize);
249 GetScale(vRootScale); // original prim size
250
251 // set the local pos and locat rot to the prims orientation and position
252 rRot = calcChildRot(rRot);
253
254 if(fPrim < 0)
255 {
256 //DebugllOwnerSay("Sleeping " + (string) (fprimNum * -1));
257 llSleep( fPrim * -1);
258 }
259 else if(fPrim > 1 ) // skip root prim
260 {
261 vPos.x *= vScaleChange.x;
262 vprimSize.x *= vScaleChange.x;
263
264 vPos.y *= vScaleChange.y;
265 vprimSize.y *= vScaleChange.y;
266
267 vPos.z *= vScaleChange.z;
268 vprimSize.z *= vScaleChange.z;
269
270 Debug("p=" + (string) fPrim
271 + " l=" + (string) vPos
272 + " r=" + (string) rRot
273 + " s=" + (string) vprimSize);
274
275 llSetLinkPrimitiveParamsFast((integer) fPrim,[PRIM_POSITION,vPos,PRIM_ROTATION,rRot,PRIM_SIZE,vprimSize]);
276 }
277 }
278 }
279 }
280 else if(num == Publish)
281 {
282 if(myNum)
283 llSleep(5); // time to delete the database and save the root prim
284 StartPublishing();
285 }
286 else
287 {
288 Debug("Bad command");
289 }
290 }
291
292
293 // use for publishing in parallel
294 http_response(key queryid, integer status, list metadata, string data)
295 {
296 if(queryid == kHttpRequestID )
297 {
298 if(status == 200) // HTTP success status
299 {
300 Debug(data);
301 if(data == "ok")
302 {
303 Put();
304 return;
305 }
306 }
307 else
308 {
309 llOwnerSay("Server Error loading animations");
310 }
311 }
312 }
313
314
315 }

Unlimited_storage_Prim_Animator

This is an example script to loop 3 animations named 'start', 'baby1', and 'baby2'

Category: Animation
By : Ferd Frederix
Created: 2011-09-07 Edited: 2011-09-07
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 integer counter;
2
3 list animations = ["start","baby1","baby2"];
4 default
5 {
7 {
9 }
10 timer()
11 {
12 string name = llList2String(animations, counter);
13 llMessageLinked(LINK_SET,1,name,"");
14
15 if(counter++ >= llGetListLength(animations)-1)
16 counter = 0;
17
18 }
19 }

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