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
Prim Super_Prim_Animator_Motion_Compiler  

Super_Prim_Animator_Motion_Compiler

This script requires the Super Prim Animator http://www.free-lsl-scripts.com/cgi/freescripts.plx?ID=1519 by Ferd Frederix. Just set up your animations as per the animator's instructions, Save it to a notecard put this script and the notecard into any prim and when you touch the prim it will print a new script into local chat. Copy everything between and including the lines /*---------- and ----------*/ anything that is not part of the script is automatically converted to comments. When the script is run it will cycle through all the animations and print a llSetMemoryLimit() command to local chat. Replace everything in the default state_entry function with that command and your script is ready to run. with a very optimized memory limit.

Category: Prim
By : Allen Firethorn
Created: 2012-11-14 Edited: 2012-11-14
Worlds: Second Life

the Zip file

Download all files for Super_Prim_Animator_Motion_Compiler
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Super_Prim_Animator_Motion_Compiler_1.lsl
1 key notecardQueryId;
2
3 // Set this to an empty string if you don't want to use the fast forms
4 string fast="Fast";
5
6 // first notecard line is line 0
7 integer notecardLine;
8 list notecardLines;
9 list animations;
10
11 //print out a line of code with the timestamp and object name commented out
12 SayCode(string code){
13 llOwnerSay("\n*/\n"+code+"\n/*");
14 }
15 default
16 {
18 notecardLine = 0;
19 notecardLines=[];
20 animations = [];
21 }
23 {
24 llOwnerSay("Reading notecard. Please wait....");
25 notecardQueryId = llGetNotecardLine("Movement", notecardLine);
26 }
27
28 dataserver(key query_id, string data)
29 {
30 if(query_id == notecardQueryId)
31 {
32 if(data == EOF){
33 string code;
34 integer i;
35 for (i = 0; i < llGetListLength(animations); i++){
36 string animationName = llList2String(animations,i);
37 llOwnerSay(animationName);
38 }
39 llOwnerSay("Done reading notecard, read " + (string)(notecardLine + 1) + " notecard lines.");
40 llOwnerSay("copy below this line and paste it into a new script\n/*----------");
41 SayCode("integer playbackchannel = 1;");
42 SayCode("rotation calcChildRot(rotation rdeltaRot){\n"+
43 "\tif(llGetAttached())\n"+
44 "\t\treturn rdeltaRot/llGetLocalRot();\n"+
45 "\telse\n"+
46 "\t\treturn rdeltaRot/llGetRootRotation();\n"+
47 "}");
48
49 // Go through the data until we find "start" to get the original scale
50 for(i = 0; i < llGetListLength(notecardLines); i++){
51 list primList = llParseString2List(llList2String(notecardLines,i),["|"],[]);
52 if(llToLower(llList2String(primList,1)) == "start"){
53 SayCode("vector originalScale = " + llList2String(primList,2)+";");
54 llSleep(0.5);
55 }
56 }
57 // Go through each animation and create a function for each one
58 for(i = 0; i < llGetListLength(animations); i ++){
59 integer j;
60 string animationName = llList2String(animations, i);
61 code= animationName+"(){\n"+
62 "\tvector currentSize = llGetScale();\n"+
63 "\tfloat scaleby = currentSize.x/originalScale.x;\n";
64 SayCode(code);
65 llSleep(0.5);
66 //Read through the list and print out the instructions for this animation
67 for(j=0; j< llGetListLength(notecardLines);j++){
68 string line = llList2String(notecardLines,j);
69 list data = llParseString2List(line,["|"],[]);
70 integer primNum = llList2Integer(data,2);
71 // Fixme negative numbers are supposed to be read as a delay
72 if(llList2String(data,1) == animationName){
73 if(primNum >1){
74 code = "\tllSetLinkPrimitiveParams"+fast+"("+llList2String(data,2)+
75 ", [PRIM_POSITION, "+llList2String(data,3)+"*scaleby, "+
76 "PRIM_ROTATION,calcChildRot("+llList2String(data,4)+"), "+
77 "PRIM_SIZE, "+llList2String(data,5)+"*scaleby]);";
78 SayCode(code);
79 llSleep(0.5);
80 } else {
81
82 SayCode("\tllSleep("+(string)(primNum*-1)+");");
83 llSleep(0.5);
84 }
85 }
86 }
87 code="}";
88 SayCode(code);
89 llSleep(0.5);
90 }
91
92 code="default{\n"+
93 "\tstate_entry(){\n"+
94 "\t\t//Paste the SetMemoryLimit() line this script prints out here\n";
95 for(i=0; i<llGetListLength(animations);i++){
96 code+="\t\t"+llList2String(animations,i)+"();\n"+
97 "\t\tllSleep(0.1);\n";
98 }
99 code += "\t\tinteger mem = llGetUsedMemory();\n"+
100 "\t\tmem=llFloor((float)mem/(float)1024)+1;\n"+
101 "\t\tmem=mem*1024;\n"+
102 "\t\tllOwnerSay(\"llSetMemoryLimit(\"+string(mem) + \");\");\n"+
103 "\t}\n";
104 SayCode(code);
105 llSleep(0.5);
106 code = "link_message(integer sender_num, integer num, string message, key id){\n"+
107 "\t\tif(num == playbackchannel){\n";
108 for(i=0; i<llGetListLength(animations);i++){
109 code+="\t\t\tif(message == \""+llList2String(animations,i)+"\"){\n"+
110 "\t\t\t\t"+llList2String(animations,i)+"();\n"+
111 "\t\t\t}\n";
112 }
113 code += "\t\t}\n"+
114 "\t}\n";
115 SayCode(code);
116 llSleep(0.5);
117 SayCode("}");
118 llSleep(0.5);
119 llOwnerSay("\n----------*/\n");
120 }
121 else
122 {
123 // Split the line up so we can strip off the timestamp and object name
124 list dList = llParseString2List(data,[":"],[]);
125 string anidata = llList2String(dList,2);
126 notecardLines+=anidata;
127
128 // Store the name of the animation if it is not already stored
129 list primList = llParseString2List(anidata,["|"],[]);
130 integer i = llListFindList(animations, [llList2String(primList,1)]);
131 string animationName = llList2String(primList,1);
132 if(i<0 && animationName != llToLower("start")){
133 animations+= animationName;
134 }
135
136 ++notecardLine;
137 notecardQueryId = llGetNotecardLine("Movement", notecardLine);
138 }
139 }
140 }
141 }

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