aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/Test sim/objects/onefang's test bed/~pose
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 20:33:54 +1000
committerDavid Walter Seikel2012-01-04 20:33:54 +1000
commitdb13ada463c2908eba68b166a9ccc4963db019f5 (patch)
treeed693d9d9532bea0d890f08199a0bcd5b1e73430 /LuaSL/Test sim/objects/onefang's test bed/~pose
parentREADME files should include at least a basic description of what it's all abo... (diff)
downloadSledjHamr-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 '')
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~pose222
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~poser200
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~poser 1200
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~poser 2200
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~poser 3200
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~poser 4200
-rw-r--r--LuaSL/Test sim/objects/onefang's test bed/~poser 5200
7 files changed, 1422 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
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}
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~poser b/LuaSL/Test sim/objects/onefang's test bed/~poser
new file mode 100644
index 0000000..fc976c4
--- /dev/null
+++ b/LuaSL/Test sim/objects/onefang's test bed/~poser
@@ -0,0 +1,200 @@
1// MPLV2 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 ch;
7string animation = "stand";
8key avatar;
9
10integer ExprEnabled = TRUE;
11string Expression;
12float ExprTimer;
13
14integer BallNum;
15
16list Expressions = [
17 ""
18 , "express_open_mouth" // 1
19 , "express_surprise_emote" // 2
20 , "express_tongue_out" // 3
21 , "express_smile" // 4
22 , "express_toothsmile" // 5
23 , "express_wink_emote" // 6
24 , "express_cry_emote" // 7
25 , "express_kiss" // 8
26 , "express_laugh_emote" // 9
27 , "express_disdain" // 10
28 , "express_repulsed_emote" // 11
29 , "express_anger_emote" // 12
30 , "express_bored_emote" // 13
31 , "express_sad_emote" // 14
32 , "express_embarrassed_emote" // 15
33 , "express_frown" // 16
34 , "express_shrug_emote" // 17
35 , "express_afraid_emote" // 18
36 , "express_worry_emote" // 19
37 , "SLEEP" // 20
38];
39
40
41stopAnim() {
42 key id = llGetPermissionsKey();
43 list anims = llGetAnimationList(id);
44 integer ix;
45 for (ix = 0; ix < llGetListLength(anims); ++ix) {
46 string anim = llList2String(anims, ix);
47 if (anim != "") {
48 llStopAnimation(anim);
49 }
50 }
51 llSetTimerEvent(0.0);
52}
53
54startAnim(string anim) {
55 if (Expression != "") {
56 if (Expression == "SLEEP") {
57 llStartAnimation("express_disdain");
58 llStartAnimation("express_smile");
59 } else {
60 llStartAnimation(Expression);
61 }
62 if (ExprEnabled) {
63 llSetTimerEvent(ExprTimer);
64 }
65 } else {
66 stopAnim();
67 }
68 if (anim != "") {
69 llStartAnimation(anim);
70 }
71}
72
73// Animation names with a "*" suffix get open mouth
74// Those with a suffix of "::" followed by a number
75// get the expression associated with that number.
76// This can optionally be followed by another "::" delim,
77// with a timer value following.
78// Return the anim name without the suffix.
79string getExpression(string anim) {
80 if (llGetSubString(anim,-1,-1) == "*") {
81 Expression = llList2String(Expressions, 1);
82 ExprTimer = 0.5;
83 return llGetSubString(anim, 0, -2);
84 }
85 integer ix = llSubStringIndex(anim, "::");
86 if (ix == -1) {
87 Expression = "";
88 ExprTimer = 0.5;
89 return anim;
90 }
91
92 list parms = llParseString2List(anim, ["::"], []);
93 anim = llList2String(parms, 0);
94 integer exprIx = (integer) llList2String(parms, 1);
95 Expression = llList2String(Expressions, exprIx);
96 ExprTimer = (float) llList2String(parms,2);
97
98 if (ExprTimer <= 0.0) {
99 ExprTimer = 0.5;
100 }
101
102 return anim;
103}
104
105getChan() {
106 BallNum = (integer) llGetSubString(llGetScriptName(),-1,-1); //offset from script name suffix
107 ch = BallNum
108 + (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
109}
110
111default {
112 state_entry() {
113 state s_on;
114 }
115}
116
117state s_on {
118 state_entry() {
119 getChan();
120 llListen(ch+8,"",NULL_KEY,"");
121 }
122
123 on_rez(integer arg) {
124 state default;
125 }
126
127 link_message(integer from, integer num, string an, key id) { //an animation is set
128 if (an == "PRIMTOUCH") {
129 return;
130 }
131
132 if (num != ch) return;
133 an = getExpression(an); // get & save expression, and return unadorned anim
134
135 if (avatar == llGetPermissionsKey()
136 && avatar != NULL_KEY
137 && animation != "") {
138 llStopAnimation(animation);
139 llMessageLinked(LINK_SET, -11002, (string)BallNum + "|" + an, avatar);
140 startAnim(an);
141 }
142 animation = an;
143 }
144
145 timer() { // timer to keep mouth open
146 if (Expression == "SLEEP") {
147 llStartAnimation("express_disdain");
148 llStartAnimation("express_smile");
149 } else if (Expression != "") {
150 llStartAnimation(Expression);
151 }
152 }
153
154 listen(integer channel, string name, key id, string str) {
155 if (str == "ALIVE" || str == "DIE") {
156 llMessageLinked(LINK_THIS,2,str,""); //send msg from ball to menu
157 if (str == "DIE") {
158 avatar = NULL_KEY;
159 llSetTimerEvent(0.0);
160 }
161 return;
162 }
163
164 avatar = (key) str; //avatar (sit) or NULL_KEY (stand up)
165 if (avatar == NULL_KEY) {
166 if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
167 stopAnim();
168 llMessageLinked(LINK_SET, -11001, (string)BallNum, llGetPermissionsKey());
169 }
170 // llReleaseControls();
171 return;
172 }
173
174 if (avatar != llGetPermissionsKey()
175 || ! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) {
176 ExprEnabled = TRUE;
177 llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
178 } else {
179 stopAnim();
180 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
181 startAnim(animation);
182 }
183 }
184
185 run_time_permissions(integer perm) {
186 if (avatar != llGetPermissionsKey()) {
187 llWhisper(DEBUG_CHANNEL, "avatar != perm key");
188 return;
189 }
190
191 if (perm & PERMISSION_TRIGGER_ANIMATION) {
192 stopAnim();
193 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
194 startAnim(animation);
195 } else {
196 llMessageLinked(LINK_SET, -11001, (string)BallNum, avatar);
197 llSetTimerEvent(0.0);
198 }
199 }
200}
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~poser 1 b/LuaSL/Test sim/objects/onefang's test bed/~poser 1
new file mode 100644
index 0000000..fc976c4
--- /dev/null
+++ b/LuaSL/Test sim/objects/onefang's test bed/~poser 1
@@ -0,0 +1,200 @@
1// MPLV2 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 ch;
7string animation = "stand";
8key avatar;
9
10integer ExprEnabled = TRUE;
11string Expression;
12float ExprTimer;
13
14integer BallNum;
15
16list Expressions = [
17 ""
18 , "express_open_mouth" // 1
19 , "express_surprise_emote" // 2
20 , "express_tongue_out" // 3
21 , "express_smile" // 4
22 , "express_toothsmile" // 5
23 , "express_wink_emote" // 6
24 , "express_cry_emote" // 7
25 , "express_kiss" // 8
26 , "express_laugh_emote" // 9
27 , "express_disdain" // 10
28 , "express_repulsed_emote" // 11
29 , "express_anger_emote" // 12
30 , "express_bored_emote" // 13
31 , "express_sad_emote" // 14
32 , "express_embarrassed_emote" // 15
33 , "express_frown" // 16
34 , "express_shrug_emote" // 17
35 , "express_afraid_emote" // 18
36 , "express_worry_emote" // 19
37 , "SLEEP" // 20
38];
39
40
41stopAnim() {
42 key id = llGetPermissionsKey();
43 list anims = llGetAnimationList(id);
44 integer ix;
45 for (ix = 0; ix < llGetListLength(anims); ++ix) {
46 string anim = llList2String(anims, ix);
47 if (anim != "") {
48 llStopAnimation(anim);
49 }
50 }
51 llSetTimerEvent(0.0);
52}
53
54startAnim(string anim) {
55 if (Expression != "") {
56 if (Expression == "SLEEP") {
57 llStartAnimation("express_disdain");
58 llStartAnimation("express_smile");
59 } else {
60 llStartAnimation(Expression);
61 }
62 if (ExprEnabled) {
63 llSetTimerEvent(ExprTimer);
64 }
65 } else {
66 stopAnim();
67 }
68 if (anim != "") {
69 llStartAnimation(anim);
70 }
71}
72
73// Animation names with a "*" suffix get open mouth
74// Those with a suffix of "::" followed by a number
75// get the expression associated with that number.
76// This can optionally be followed by another "::" delim,
77// with a timer value following.
78// Return the anim name without the suffix.
79string getExpression(string anim) {
80 if (llGetSubString(anim,-1,-1) == "*") {
81 Expression = llList2String(Expressions, 1);
82 ExprTimer = 0.5;
83 return llGetSubString(anim, 0, -2);
84 }
85 integer ix = llSubStringIndex(anim, "::");
86 if (ix == -1) {
87 Expression = "";
88 ExprTimer = 0.5;
89 return anim;
90 }
91
92 list parms = llParseString2List(anim, ["::"], []);
93 anim = llList2String(parms, 0);
94 integer exprIx = (integer) llList2String(parms, 1);
95 Expression = llList2String(Expressions, exprIx);
96 ExprTimer = (float) llList2String(parms,2);
97
98 if (ExprTimer <= 0.0) {
99 ExprTimer = 0.5;
100 }
101
102 return anim;
103}
104
105getChan() {
106 BallNum = (integer) llGetSubString(llGetScriptName(),-1,-1); //offset from script name suffix
107 ch = BallNum
108 + (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
109}
110
111default {
112 state_entry() {
113 state s_on;
114 }
115}
116
117state s_on {
118 state_entry() {
119 getChan();
120 llListen(ch+8,"",NULL_KEY,"");
121 }
122
123 on_rez(integer arg) {
124 state default;
125 }
126
127 link_message(integer from, integer num, string an, key id) { //an animation is set
128 if (an == "PRIMTOUCH") {
129 return;
130 }
131
132 if (num != ch) return;
133 an = getExpression(an); // get & save expression, and return unadorned anim
134
135 if (avatar == llGetPermissionsKey()
136 && avatar != NULL_KEY
137 && animation != "") {
138 llStopAnimation(animation);
139 llMessageLinked(LINK_SET, -11002, (string)BallNum + "|" + an, avatar);
140 startAnim(an);
141 }
142 animation = an;
143 }
144
145 timer() { // timer to keep mouth open
146 if (Expression == "SLEEP") {
147 llStartAnimation("express_disdain");
148 llStartAnimation("express_smile");
149 } else if (Expression != "") {
150 llStartAnimation(Expression);
151 }
152 }
153
154 listen(integer channel, string name, key id, string str) {
155 if (str == "ALIVE" || str == "DIE") {
156 llMessageLinked(LINK_THIS,2,str,""); //send msg from ball to menu
157 if (str == "DIE") {
158 avatar = NULL_KEY;
159 llSetTimerEvent(0.0);
160 }
161 return;
162 }
163
164 avatar = (key) str; //avatar (sit) or NULL_KEY (stand up)
165 if (avatar == NULL_KEY) {
166 if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
167 stopAnim();
168 llMessageLinked(LINK_SET, -11001, (string)BallNum, llGetPermissionsKey());
169 }
170 // llReleaseControls();
171 return;
172 }
173
174 if (avatar != llGetPermissionsKey()
175 || ! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) {
176 ExprEnabled = TRUE;
177 llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
178 } else {
179 stopAnim();
180 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
181 startAnim(animation);
182 }
183 }
184
185 run_time_permissions(integer perm) {
186 if (avatar != llGetPermissionsKey()) {
187 llWhisper(DEBUG_CHANNEL, "avatar != perm key");
188 return;
189 }
190
191 if (perm & PERMISSION_TRIGGER_ANIMATION) {
192 stopAnim();
193 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
194 startAnim(animation);
195 } else {
196 llMessageLinked(LINK_SET, -11001, (string)BallNum, avatar);
197 llSetTimerEvent(0.0);
198 }
199 }
200}
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~poser 2 b/LuaSL/Test sim/objects/onefang's test bed/~poser 2
new file mode 100644
index 0000000..fc976c4
--- /dev/null
+++ b/LuaSL/Test sim/objects/onefang's test bed/~poser 2
@@ -0,0 +1,200 @@
1// MPLV2 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 ch;
7string animation = "stand";
8key avatar;
9
10integer ExprEnabled = TRUE;
11string Expression;
12float ExprTimer;
13
14integer BallNum;
15
16list Expressions = [
17 ""
18 , "express_open_mouth" // 1
19 , "express_surprise_emote" // 2
20 , "express_tongue_out" // 3
21 , "express_smile" // 4
22 , "express_toothsmile" // 5
23 , "express_wink_emote" // 6
24 , "express_cry_emote" // 7
25 , "express_kiss" // 8
26 , "express_laugh_emote" // 9
27 , "express_disdain" // 10
28 , "express_repulsed_emote" // 11
29 , "express_anger_emote" // 12
30 , "express_bored_emote" // 13
31 , "express_sad_emote" // 14
32 , "express_embarrassed_emote" // 15
33 , "express_frown" // 16
34 , "express_shrug_emote" // 17
35 , "express_afraid_emote" // 18
36 , "express_worry_emote" // 19
37 , "SLEEP" // 20
38];
39
40
41stopAnim() {
42 key id = llGetPermissionsKey();
43 list anims = llGetAnimationList(id);
44 integer ix;
45 for (ix = 0; ix < llGetListLength(anims); ++ix) {
46 string anim = llList2String(anims, ix);
47 if (anim != "") {
48 llStopAnimation(anim);
49 }
50 }
51 llSetTimerEvent(0.0);
52}
53
54startAnim(string anim) {
55 if (Expression != "") {
56 if (Expression == "SLEEP") {
57 llStartAnimation("express_disdain");
58 llStartAnimation("express_smile");
59 } else {
60 llStartAnimation(Expression);
61 }
62 if (ExprEnabled) {
63 llSetTimerEvent(ExprTimer);
64 }
65 } else {
66 stopAnim();
67 }
68 if (anim != "") {
69 llStartAnimation(anim);
70 }
71}
72
73// Animation names with a "*" suffix get open mouth
74// Those with a suffix of "::" followed by a number
75// get the expression associated with that number.
76// This can optionally be followed by another "::" delim,
77// with a timer value following.
78// Return the anim name without the suffix.
79string getExpression(string anim) {
80 if (llGetSubString(anim,-1,-1) == "*") {
81 Expression = llList2String(Expressions, 1);
82 ExprTimer = 0.5;
83 return llGetSubString(anim, 0, -2);
84 }
85 integer ix = llSubStringIndex(anim, "::");
86 if (ix == -1) {
87 Expression = "";
88 ExprTimer = 0.5;
89 return anim;
90 }
91
92 list parms = llParseString2List(anim, ["::"], []);
93 anim = llList2String(parms, 0);
94 integer exprIx = (integer) llList2String(parms, 1);
95 Expression = llList2String(Expressions, exprIx);
96 ExprTimer = (float) llList2String(parms,2);
97
98 if (ExprTimer <= 0.0) {
99 ExprTimer = 0.5;
100 }
101
102 return anim;
103}
104
105getChan() {
106 BallNum = (integer) llGetSubString(llGetScriptName(),-1,-1); //offset from script name suffix
107 ch = BallNum
108 + (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
109}
110
111default {
112 state_entry() {
113 state s_on;
114 }
115}
116
117state s_on {
118 state_entry() {
119 getChan();
120 llListen(ch+8,"",NULL_KEY,"");
121 }
122
123 on_rez(integer arg) {
124 state default;
125 }
126
127 link_message(integer from, integer num, string an, key id) { //an animation is set
128 if (an == "PRIMTOUCH") {
129 return;
130 }
131
132 if (num != ch) return;
133 an = getExpression(an); // get & save expression, and return unadorned anim
134
135 if (avatar == llGetPermissionsKey()
136 && avatar != NULL_KEY
137 && animation != "") {
138 llStopAnimation(animation);
139 llMessageLinked(LINK_SET, -11002, (string)BallNum + "|" + an, avatar);
140 startAnim(an);
141 }
142 animation = an;
143 }
144
145 timer() { // timer to keep mouth open
146 if (Expression == "SLEEP") {
147 llStartAnimation("express_disdain");
148 llStartAnimation("express_smile");
149 } else if (Expression != "") {
150 llStartAnimation(Expression);
151 }
152 }
153
154 listen(integer channel, string name, key id, string str) {
155 if (str == "ALIVE" || str == "DIE") {
156 llMessageLinked(LINK_THIS,2,str,""); //send msg from ball to menu
157 if (str == "DIE") {
158 avatar = NULL_KEY;
159 llSetTimerEvent(0.0);
160 }
161 return;
162 }
163
164 avatar = (key) str; //avatar (sit) or NULL_KEY (stand up)
165 if (avatar == NULL_KEY) {
166 if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
167 stopAnim();
168 llMessageLinked(LINK_SET, -11001, (string)BallNum, llGetPermissionsKey());
169 }
170 // llReleaseControls();
171 return;
172 }
173
174 if (avatar != llGetPermissionsKey()
175 || ! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) {
176 ExprEnabled = TRUE;
177 llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
178 } else {
179 stopAnim();
180 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
181 startAnim(animation);
182 }
183 }
184
185 run_time_permissions(integer perm) {
186 if (avatar != llGetPermissionsKey()) {
187 llWhisper(DEBUG_CHANNEL, "avatar != perm key");
188 return;
189 }
190
191 if (perm & PERMISSION_TRIGGER_ANIMATION) {
192 stopAnim();
193 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
194 startAnim(animation);
195 } else {
196 llMessageLinked(LINK_SET, -11001, (string)BallNum, avatar);
197 llSetTimerEvent(0.0);
198 }
199 }
200}
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~poser 3 b/LuaSL/Test sim/objects/onefang's test bed/~poser 3
new file mode 100644
index 0000000..fc976c4
--- /dev/null
+++ b/LuaSL/Test sim/objects/onefang's test bed/~poser 3
@@ -0,0 +1,200 @@
1// MPLV2 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 ch;
7string animation = "stand";
8key avatar;
9
10integer ExprEnabled = TRUE;
11string Expression;
12float ExprTimer;
13
14integer BallNum;
15
16list Expressions = [
17 ""
18 , "express_open_mouth" // 1
19 , "express_surprise_emote" // 2
20 , "express_tongue_out" // 3
21 , "express_smile" // 4
22 , "express_toothsmile" // 5
23 , "express_wink_emote" // 6
24 , "express_cry_emote" // 7
25 , "express_kiss" // 8
26 , "express_laugh_emote" // 9
27 , "express_disdain" // 10
28 , "express_repulsed_emote" // 11
29 , "express_anger_emote" // 12
30 , "express_bored_emote" // 13
31 , "express_sad_emote" // 14
32 , "express_embarrassed_emote" // 15
33 , "express_frown" // 16
34 , "express_shrug_emote" // 17
35 , "express_afraid_emote" // 18
36 , "express_worry_emote" // 19
37 , "SLEEP" // 20
38];
39
40
41stopAnim() {
42 key id = llGetPermissionsKey();
43 list anims = llGetAnimationList(id);
44 integer ix;
45 for (ix = 0; ix < llGetListLength(anims); ++ix) {
46 string anim = llList2String(anims, ix);
47 if (anim != "") {
48 llStopAnimation(anim);
49 }
50 }
51 llSetTimerEvent(0.0);
52}
53
54startAnim(string anim) {
55 if (Expression != "") {
56 if (Expression == "SLEEP") {
57 llStartAnimation("express_disdain");
58 llStartAnimation("express_smile");
59 } else {
60 llStartAnimation(Expression);
61 }
62 if (ExprEnabled) {
63 llSetTimerEvent(ExprTimer);
64 }
65 } else {
66 stopAnim();
67 }
68 if (anim != "") {
69 llStartAnimation(anim);
70 }
71}
72
73// Animation names with a "*" suffix get open mouth
74// Those with a suffix of "::" followed by a number
75// get the expression associated with that number.
76// This can optionally be followed by another "::" delim,
77// with a timer value following.
78// Return the anim name without the suffix.
79string getExpression(string anim) {
80 if (llGetSubString(anim,-1,-1) == "*") {
81 Expression = llList2String(Expressions, 1);
82 ExprTimer = 0.5;
83 return llGetSubString(anim, 0, -2);
84 }
85 integer ix = llSubStringIndex(anim, "::");
86 if (ix == -1) {
87 Expression = "";
88 ExprTimer = 0.5;
89 return anim;
90 }
91
92 list parms = llParseString2List(anim, ["::"], []);
93 anim = llList2String(parms, 0);
94 integer exprIx = (integer) llList2String(parms, 1);
95 Expression = llList2String(Expressions, exprIx);
96 ExprTimer = (float) llList2String(parms,2);
97
98 if (ExprTimer <= 0.0) {
99 ExprTimer = 0.5;
100 }
101
102 return anim;
103}
104
105getChan() {
106 BallNum = (integer) llGetSubString(llGetScriptName(),-1,-1); //offset from script name suffix
107 ch = BallNum
108 + (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
109}
110
111default {
112 state_entry() {
113 state s_on;
114 }
115}
116
117state s_on {
118 state_entry() {
119 getChan();
120 llListen(ch+8,"",NULL_KEY,"");
121 }
122
123 on_rez(integer arg) {
124 state default;
125 }
126
127 link_message(integer from, integer num, string an, key id) { //an animation is set
128 if (an == "PRIMTOUCH") {
129 return;
130 }
131
132 if (num != ch) return;
133 an = getExpression(an); // get & save expression, and return unadorned anim
134
135 if (avatar == llGetPermissionsKey()
136 && avatar != NULL_KEY
137 && animation != "") {
138 llStopAnimation(animation);
139 llMessageLinked(LINK_SET, -11002, (string)BallNum + "|" + an, avatar);
140 startAnim(an);
141 }
142 animation = an;
143 }
144
145 timer() { // timer to keep mouth open
146 if (Expression == "SLEEP") {
147 llStartAnimation("express_disdain");
148 llStartAnimation("express_smile");
149 } else if (Expression != "") {
150 llStartAnimation(Expression);
151 }
152 }
153
154 listen(integer channel, string name, key id, string str) {
155 if (str == "ALIVE" || str == "DIE") {
156 llMessageLinked(LINK_THIS,2,str,""); //send msg from ball to menu
157 if (str == "DIE") {
158 avatar = NULL_KEY;
159 llSetTimerEvent(0.0);
160 }
161 return;
162 }
163
164 avatar = (key) str; //avatar (sit) or NULL_KEY (stand up)
165 if (avatar == NULL_KEY) {
166 if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
167 stopAnim();
168 llMessageLinked(LINK_SET, -11001, (string)BallNum, llGetPermissionsKey());
169 }
170 // llReleaseControls();
171 return;
172 }
173
174 if (avatar != llGetPermissionsKey()
175 || ! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) {
176 ExprEnabled = TRUE;
177 llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
178 } else {
179 stopAnim();
180 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
181 startAnim(animation);
182 }
183 }
184
185 run_time_permissions(integer perm) {
186 if (avatar != llGetPermissionsKey()) {
187 llWhisper(DEBUG_CHANNEL, "avatar != perm key");
188 return;
189 }
190
191 if (perm & PERMISSION_TRIGGER_ANIMATION) {
192 stopAnim();
193 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
194 startAnim(animation);
195 } else {
196 llMessageLinked(LINK_SET, -11001, (string)BallNum, avatar);
197 llSetTimerEvent(0.0);
198 }
199 }
200}
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~poser 4 b/LuaSL/Test sim/objects/onefang's test bed/~poser 4
new file mode 100644
index 0000000..fc976c4
--- /dev/null
+++ b/LuaSL/Test sim/objects/onefang's test bed/~poser 4
@@ -0,0 +1,200 @@
1// MPLV2 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 ch;
7string animation = "stand";
8key avatar;
9
10integer ExprEnabled = TRUE;
11string Expression;
12float ExprTimer;
13
14integer BallNum;
15
16list Expressions = [
17 ""
18 , "express_open_mouth" // 1
19 , "express_surprise_emote" // 2
20 , "express_tongue_out" // 3
21 , "express_smile" // 4
22 , "express_toothsmile" // 5
23 , "express_wink_emote" // 6
24 , "express_cry_emote" // 7
25 , "express_kiss" // 8
26 , "express_laugh_emote" // 9
27 , "express_disdain" // 10
28 , "express_repulsed_emote" // 11
29 , "express_anger_emote" // 12
30 , "express_bored_emote" // 13
31 , "express_sad_emote" // 14
32 , "express_embarrassed_emote" // 15
33 , "express_frown" // 16
34 , "express_shrug_emote" // 17
35 , "express_afraid_emote" // 18
36 , "express_worry_emote" // 19
37 , "SLEEP" // 20
38];
39
40
41stopAnim() {
42 key id = llGetPermissionsKey();
43 list anims = llGetAnimationList(id);
44 integer ix;
45 for (ix = 0; ix < llGetListLength(anims); ++ix) {
46 string anim = llList2String(anims, ix);
47 if (anim != "") {
48 llStopAnimation(anim);
49 }
50 }
51 llSetTimerEvent(0.0);
52}
53
54startAnim(string anim) {
55 if (Expression != "") {
56 if (Expression == "SLEEP") {
57 llStartAnimation("express_disdain");
58 llStartAnimation("express_smile");
59 } else {
60 llStartAnimation(Expression);
61 }
62 if (ExprEnabled) {
63 llSetTimerEvent(ExprTimer);
64 }
65 } else {
66 stopAnim();
67 }
68 if (anim != "") {
69 llStartAnimation(anim);
70 }
71}
72
73// Animation names with a "*" suffix get open mouth
74// Those with a suffix of "::" followed by a number
75// get the expression associated with that number.
76// This can optionally be followed by another "::" delim,
77// with a timer value following.
78// Return the anim name without the suffix.
79string getExpression(string anim) {
80 if (llGetSubString(anim,-1,-1) == "*") {
81 Expression = llList2String(Expressions, 1);
82 ExprTimer = 0.5;
83 return llGetSubString(anim, 0, -2);
84 }
85 integer ix = llSubStringIndex(anim, "::");
86 if (ix == -1) {
87 Expression = "";
88 ExprTimer = 0.5;
89 return anim;
90 }
91
92 list parms = llParseString2List(anim, ["::"], []);
93 anim = llList2String(parms, 0);
94 integer exprIx = (integer) llList2String(parms, 1);
95 Expression = llList2String(Expressions, exprIx);
96 ExprTimer = (float) llList2String(parms,2);
97
98 if (ExprTimer <= 0.0) {
99 ExprTimer = 0.5;
100 }
101
102 return anim;
103}
104
105getChan() {
106 BallNum = (integer) llGetSubString(llGetScriptName(),-1,-1); //offset from script name suffix
107 ch = BallNum
108 + (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
109}
110
111default {
112 state_entry() {
113 state s_on;
114 }
115}
116
117state s_on {
118 state_entry() {
119 getChan();
120 llListen(ch+8,"",NULL_KEY,"");
121 }
122
123 on_rez(integer arg) {
124 state default;
125 }
126
127 link_message(integer from, integer num, string an, key id) { //an animation is set
128 if (an == "PRIMTOUCH") {
129 return;
130 }
131
132 if (num != ch) return;
133 an = getExpression(an); // get & save expression, and return unadorned anim
134
135 if (avatar == llGetPermissionsKey()
136 && avatar != NULL_KEY
137 && animation != "") {
138 llStopAnimation(animation);
139 llMessageLinked(LINK_SET, -11002, (string)BallNum + "|" + an, avatar);
140 startAnim(an);
141 }
142 animation = an;
143 }
144
145 timer() { // timer to keep mouth open
146 if (Expression == "SLEEP") {
147 llStartAnimation("express_disdain");
148 llStartAnimation("express_smile");
149 } else if (Expression != "") {
150 llStartAnimation(Expression);
151 }
152 }
153
154 listen(integer channel, string name, key id, string str) {
155 if (str == "ALIVE" || str == "DIE") {
156 llMessageLinked(LINK_THIS,2,str,""); //send msg from ball to menu
157 if (str == "DIE") {
158 avatar = NULL_KEY;
159 llSetTimerEvent(0.0);
160 }
161 return;
162 }
163
164 avatar = (key) str; //avatar (sit) or NULL_KEY (stand up)
165 if (avatar == NULL_KEY) {
166 if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
167 stopAnim();
168 llMessageLinked(LINK_SET, -11001, (string)BallNum, llGetPermissionsKey());
169 }
170 // llReleaseControls();
171 return;
172 }
173
174 if (avatar != llGetPermissionsKey()
175 || ! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) {
176 ExprEnabled = TRUE;
177 llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
178 } else {
179 stopAnim();
180 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
181 startAnim(animation);
182 }
183 }
184
185 run_time_permissions(integer perm) {
186 if (avatar != llGetPermissionsKey()) {
187 llWhisper(DEBUG_CHANNEL, "avatar != perm key");
188 return;
189 }
190
191 if (perm & PERMISSION_TRIGGER_ANIMATION) {
192 stopAnim();
193 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
194 startAnim(animation);
195 } else {
196 llMessageLinked(LINK_SET, -11001, (string)BallNum, avatar);
197 llSetTimerEvent(0.0);
198 }
199 }
200}
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~poser 5 b/LuaSL/Test sim/objects/onefang's test bed/~poser 5
new file mode 100644
index 0000000..fc976c4
--- /dev/null
+++ b/LuaSL/Test sim/objects/onefang's test bed/~poser 5
@@ -0,0 +1,200 @@
1// MPLV2 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 ch;
7string animation = "stand";
8key avatar;
9
10integer ExprEnabled = TRUE;
11string Expression;
12float ExprTimer;
13
14integer BallNum;
15
16list Expressions = [
17 ""
18 , "express_open_mouth" // 1
19 , "express_surprise_emote" // 2
20 , "express_tongue_out" // 3
21 , "express_smile" // 4
22 , "express_toothsmile" // 5
23 , "express_wink_emote" // 6
24 , "express_cry_emote" // 7
25 , "express_kiss" // 8
26 , "express_laugh_emote" // 9
27 , "express_disdain" // 10
28 , "express_repulsed_emote" // 11
29 , "express_anger_emote" // 12
30 , "express_bored_emote" // 13
31 , "express_sad_emote" // 14
32 , "express_embarrassed_emote" // 15
33 , "express_frown" // 16
34 , "express_shrug_emote" // 17
35 , "express_afraid_emote" // 18
36 , "express_worry_emote" // 19
37 , "SLEEP" // 20
38];
39
40
41stopAnim() {
42 key id = llGetPermissionsKey();
43 list anims = llGetAnimationList(id);
44 integer ix;
45 for (ix = 0; ix < llGetListLength(anims); ++ix) {
46 string anim = llList2String(anims, ix);
47 if (anim != "") {
48 llStopAnimation(anim);
49 }
50 }
51 llSetTimerEvent(0.0);
52}
53
54startAnim(string anim) {
55 if (Expression != "") {
56 if (Expression == "SLEEP") {
57 llStartAnimation("express_disdain");
58 llStartAnimation("express_smile");
59 } else {
60 llStartAnimation(Expression);
61 }
62 if (ExprEnabled) {
63 llSetTimerEvent(ExprTimer);
64 }
65 } else {
66 stopAnim();
67 }
68 if (anim != "") {
69 llStartAnimation(anim);
70 }
71}
72
73// Animation names with a "*" suffix get open mouth
74// Those with a suffix of "::" followed by a number
75// get the expression associated with that number.
76// This can optionally be followed by another "::" delim,
77// with a timer value following.
78// Return the anim name without the suffix.
79string getExpression(string anim) {
80 if (llGetSubString(anim,-1,-1) == "*") {
81 Expression = llList2String(Expressions, 1);
82 ExprTimer = 0.5;
83 return llGetSubString(anim, 0, -2);
84 }
85 integer ix = llSubStringIndex(anim, "::");
86 if (ix == -1) {
87 Expression = "";
88 ExprTimer = 0.5;
89 return anim;
90 }
91
92 list parms = llParseString2List(anim, ["::"], []);
93 anim = llList2String(parms, 0);
94 integer exprIx = (integer) llList2String(parms, 1);
95 Expression = llList2String(Expressions, exprIx);
96 ExprTimer = (float) llList2String(parms,2);
97
98 if (ExprTimer <= 0.0) {
99 ExprTimer = 0.5;
100 }
101
102 return anim;
103}
104
105getChan() {
106 BallNum = (integer) llGetSubString(llGetScriptName(),-1,-1); //offset from script name suffix
107 ch = BallNum
108 + (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
109}
110
111default {
112 state_entry() {
113 state s_on;
114 }
115}
116
117state s_on {
118 state_entry() {
119 getChan();
120 llListen(ch+8,"",NULL_KEY,"");
121 }
122
123 on_rez(integer arg) {
124 state default;
125 }
126
127 link_message(integer from, integer num, string an, key id) { //an animation is set
128 if (an == "PRIMTOUCH") {
129 return;
130 }
131
132 if (num != ch) return;
133 an = getExpression(an); // get & save expression, and return unadorned anim
134
135 if (avatar == llGetPermissionsKey()
136 && avatar != NULL_KEY
137 && animation != "") {
138 llStopAnimation(animation);
139 llMessageLinked(LINK_SET, -11002, (string)BallNum + "|" + an, avatar);
140 startAnim(an);
141 }
142 animation = an;
143 }
144
145 timer() { // timer to keep mouth open
146 if (Expression == "SLEEP") {
147 llStartAnimation("express_disdain");
148 llStartAnimation("express_smile");
149 } else if (Expression != "") {
150 llStartAnimation(Expression);
151 }
152 }
153
154 listen(integer channel, string name, key id, string str) {
155 if (str == "ALIVE" || str == "DIE") {
156 llMessageLinked(LINK_THIS,2,str,""); //send msg from ball to menu
157 if (str == "DIE") {
158 avatar = NULL_KEY;
159 llSetTimerEvent(0.0);
160 }
161 return;
162 }
163
164 avatar = (key) str; //avatar (sit) or NULL_KEY (stand up)
165 if (avatar == NULL_KEY) {
166 if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
167 stopAnim();
168 llMessageLinked(LINK_SET, -11001, (string)BallNum, llGetPermissionsKey());
169 }
170 // llReleaseControls();
171 return;
172 }
173
174 if (avatar != llGetPermissionsKey()
175 || ! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) {
176 ExprEnabled = TRUE;
177 llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
178 } else {
179 stopAnim();
180 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
181 startAnim(animation);
182 }
183 }
184
185 run_time_permissions(integer perm) {
186 if (avatar != llGetPermissionsKey()) {
187 llWhisper(DEBUG_CHANNEL, "avatar != perm key");
188 return;
189 }
190
191 if (perm & PERMISSION_TRIGGER_ANIMATION) {
192 stopAnim();
193 llMessageLinked(LINK_SET, -11000, (string)BallNum + "|" + animation, avatar);
194 startAnim(animation);
195 } else {
196 llMessageLinked(LINK_SET, -11001, (string)BallNum, avatar);
197 llSetTimerEvent(0.0);
198 }
199 }
200}