aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/media/Test%20sim/onefang%27s%20test%20bed/~pose.lsl
diff options
context:
space:
mode:
Diffstat (limited to 'media/Test%20sim/onefang%27s%20test%20bed/~pose.lsl')
-rw-r--r--media/Test%20sim/onefang%27s%20test%20bed/~pose.lsl222
1 files changed, 222 insertions, 0 deletions
diff --git a/media/Test%20sim/onefang%27s%20test%20bed/~pose.lsl b/media/Test%20sim/onefang%27s%20test%20bed/~pose.lsl
new file mode 100644
index 0000000..26ab5ff
--- /dev/null
+++ b/media/Test%20sim/onefang%27s%20test%20bed/~pose.lsl
@@ -0,0 +1,222 @@
1// MLPV2 Version 2.3, by Learjeff Innis, based on
2// MLP MULTI-LOVE-POSE V1.2 - Copyright (c) 2006, by Miffy Fluffy (BSD License)
3// OpenSim port by Jez Ember
4// Meta 7 fixes by onefang Rejected
5
6integer MAX_AVS = 6;
7
8integer a;
9integer ch;
10integer i;
11integer swap;
12string an1;
13string an2;
14string an3;
15string an4;
16string an5;
17string an6;
18string pose;
19
20list PRs; // pos/rot pairs for Save
21
22list anims; // strided list of anims, indexed by pose*6
23vector pos;
24rotation rot;
25integer BallCount; // number of balls
26integer UpdateCount; // number of balls we've heard from, for save
27
28string prStr(string str) {
29 i = llSubStringIndex(str,">");
30 vector p = ((vector)llGetSubString(str,0,i) - pos) / rot;
31 vector r = llRot2Euler((rotation)llGetSubString(str,i+1,-1) / rot)*RAD_TO_DEG;
32 return "<"+round(p.x, 3)+","+round(p.y, 3)+","+round(p.z, 3)+"> <"+round(r.x, 1)+","+round(r.y, 1)+","+round(r.z, 1)+">";
33}
34
35string round(float number, integer places) {
36 float shifted;
37 integer rounded;
38 string s;
39 shifted = number * llPow(10.0,(float)places);
40 rounded = llRound(shifted);
41 s = (string)((float)rounded / llPow(10.0,(float)places));
42 rounded = llSubStringIndex(s, ".");
43 if (-1 != rounded)
44 s = llGetSubString(s,0,llSubStringIndex(s, ".")+places);
45 else
46 {
47 s += ".00000000";
48 s = llGetSubString(s,0,llSubStringIndex(s, ".")+places);
49 }
50 return s;
51}
52
53check_anim(string aname) {
54 if (aname == "") {
55 return;
56 }
57 if ( aname != "PINK"
58 && aname != "BLUE"
59 && aname != "stand"
60 && aname != "sit_ground") {
61
62 // ignore expression suffix of "*" or "::nnn"
63 if (llGetSubString(aname, -1, -1) == "*") {
64 aname = llGetSubString(aname, 0, -2);
65 } else {
66 integer ix = llSubStringIndex(aname, "::");
67 if (ix != -1) {
68 aname = llGetSubString(aname, 0, ix-1);
69 }
70 }
71
72 if (llGetInventoryType(aname) != INVENTORY_ANIMATION) {
73 llSay(0,"animation '"
74 + aname
75 + "' not in inventory (ok for build-in animations, otherwise check)");
76 }
77 }
78}
79
80getChan() {
81 ch = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
82}
83
84default {
85
86 link_message(integer from, integer num, string data, key id) {
87 if (num != 9+a) return;
88
89 if (data == "LOADED") state on;
90
91 list ldata = llParseString2List(data,[" | "," | "," | "," | "," |","| ","|"],[]);
92
93 an1 = llList2String(ldata,1);
94 an2 = llList2String(ldata,2);
95 an3 = llList2String(ldata,3);
96 an4 = llList2String(ldata,4);
97 an5 = llList2String(ldata,5);
98 an6 = llList2String(ldata,6);
99
100 if (a>1) {
101 check_anim(an1);
102 check_anim(an2);
103 check_anim(an3);
104 check_anim(an4);
105 check_anim(an5);
106 check_anim(an6);
107 } else if (a) { //pose1: set default
108 if (an1 == "") an1 = "sit_ground";
109 if (an2 == "") an2 = "sit_ground";
110 if (an3 == "") an3 = "sit_ground";
111 if (an4 == "") an4 = "sit_ground";
112 if (an5 == "") an5 = "sit_ground";
113 if (an6 == "") an6 = "sit_ground";
114 } else { //pose0: set stand
115 if (an1 == "") an1 = "stand";
116 if (an2 == "") an2 = "stand";
117 if (an3 == "") an3 = "stand";
118 if (an4 == "") an4 = "stand";
119 if (an5 == "") an5 = "stand";
120 if (an6 == "") an6 = "stand";
121 }
122 anims += [ an1, an2, an3, an4, an5, an6 ];
123 ++a;
124 }
125 state_exit() {
126 llOwnerSay((string)a+" poses loaded ("+llGetScriptName()+": "+(string)llGetFreeMemory()+" bytes free)");
127 }
128}
129
130
131state on {
132 state_entry() {
133 getChan();
134 }
135
136 on_rez(integer arg) {
137 getChan();
138 }
139
140 link_message(integer from, integer num, string cmd, key akey) {
141 if (cmd == "PRIMTOUCH"){
142 return;
143 }
144 if (num) return;
145 if (cmd == "POSE") {
146 list parms = llCSV2List((string)akey);
147 BallCount = llList2Integer(parms,1);
148 a = llList2Integer(parms,0) * 6;
149 an1 = llList2String(anims, a);
150 an2 = llList2String(anims, a+1);
151 an3 = llList2String(anims, a+2);
152 an4 = llList2String(anims, a+3);
153 an5 = llList2String(anims, a+4);
154 an6 = llList2String(anims, a+5);
155 } else if (cmd == "SWAP") {
156 swap = !swap;
157 } else if (cmd == "SAVE") {
158 pose = (string)akey;
159 state save;
160 } else return;
161 llMessageLinked(LINK_THIS,ch+swap, an1,(key)""); //msg to poser 1/2
162 llMessageLinked(LINK_THIS,ch+!swap,an2,(key)"");
163 llMessageLinked(LINK_THIS,ch+2, an3,(key)""); //msg to poser 3
164 llMessageLinked(LINK_THIS,ch+3, an4,(key)""); //msg to poser 4
165 llMessageLinked(LINK_THIS,ch+4, an5,(key)""); //msg to poser 4
166 llMessageLinked(LINK_THIS,ch+5, an6,(key)""); //msg to poser 4
167 }
168}
169
170state save {
171 state_entry() {
172 llMessageLinked(LINK_THIS,0,"GETREFPOS",""); //msg to pos: ask ref position
173 integer ix;
174 PRs = [ "", "", "", "", "", "" ];
175
176 for (ix = 0; ix < MAX_AVS; ++ix) {
177 llListen(ch+16+ix, "", NULL_KEY, "");
178 llSay(ch+ix,"SAVE"); //msg to balls
179 }
180 llSetTimerEvent(3);
181 UpdateCount = 0;
182 }
183
184
185 listen(integer channel, string name, key id, string pr) {
186 channel -= (ch + 16);
187
188 if (channel == 0) {
189 channel = channel + swap;
190 } else if (channel == 1) {
191 channel = channel - swap;
192 }
193
194 PRs = llListReplaceList(PRs, (list)pr, channel, channel);
195
196 if (++UpdateCount == BallCount) {
197 pr = "";
198 integer ix;
199 for (ix = 0; ix < BallCount; ++ix) {
200 pr += prStr(llList2String(PRs, ix)) + " ";
201 }
202
203 llOwnerSay("{"+pose+"} "+pr);
204 llMessageLinked(LINK_THIS,1,pose,pr); //write to memory
205 state on;
206 }
207 }
208 link_message(integer from, integer num, string posstr, key rotkey) {
209 if (posstr == "PRIMTOUCH"){
210 return;
211 }
212 if (num != 8) return;
213 pos = (vector)posstr; //revtrieve reference position from pos
214 rot = (rotation)((string)rotkey);
215 }
216 timer() {
217 state on;
218 }
219 state_exit() {
220 llSetTimerEvent(0);
221 }
222}