diff options
author | David Walter Seikel | 2012-01-04 20:33:54 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 20:33:54 +1000 |
commit | db13ada463c2908eba68b166a9ccc4963db019f5 (patch) | |
tree | ed693d9d9532bea0d890f08199a0bcd5b1e73430 /LuaSL/Test sim/objects/onefang's test bed/~pose | |
parent | README files should include at least a basic description of what it's all abo... (diff) | |
download | SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.zip SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.tar.gz SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.tar.bz2 SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.tar.xz |
Add a test sim with an MLP bed in it.
No animations yet, wont need them until later, maybe wont need them until this is ready for in world testing.
Diffstat (limited to 'LuaSL/Test sim/objects/onefang's test bed/~pose')
-rw-r--r-- | LuaSL/Test sim/objects/onefang's test bed/~pose | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~pose b/LuaSL/Test sim/objects/onefang's test bed/~pose new file mode 100644 index 0000000..26ab5ff --- /dev/null +++ b/LuaSL/Test sim/objects/onefang's test bed/~pose | |||
@@ -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 | |||
6 | integer MAX_AVS = 6; | ||
7 | |||
8 | integer a; | ||
9 | integer ch; | ||
10 | integer i; | ||
11 | integer swap; | ||
12 | string an1; | ||
13 | string an2; | ||
14 | string an3; | ||
15 | string an4; | ||
16 | string an5; | ||
17 | string an6; | ||
18 | string pose; | ||
19 | |||
20 | list PRs; // pos/rot pairs for Save | ||
21 | |||
22 | list anims; // strided list of anims, indexed by pose*6 | ||
23 | vector pos; | ||
24 | rotation rot; | ||
25 | integer BallCount; // number of balls | ||
26 | integer UpdateCount; // number of balls we've heard from, for save | ||
27 | |||
28 | string 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 | |||
35 | string 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 | |||
53 | check_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 | |||
80 | getChan() { | ||
81 | ch = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim | ||
82 | } | ||
83 | |||
84 | default { | ||
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 | |||
131 | state 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 | |||
170 | state 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 | } | ||