-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnPose Sequencer V3.lsl
238 lines (212 loc) · 10 KB
/
nPose Sequencer V3.lsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
key kQuery; //used for dataserver to sort out if this is the response we looking for
integer iLine = 0; //notecard line number
float posePause = 0.0; //used to set the pose time for the current pose
string loadedCard; //name of the notecard which is sent to dataserver for reading. will only change if someone selects another sequence to run
string cardToRun = "";
integer loopTo = 0; //line number where LOOPTO occurs. if no LOOPTO line in notecard this remains at line 0
integer loopToSkipper = 0; //used in isPaused state to move in front of or one after LOOPTO depending on if prev or next brings us to this line.
default{
state_entry(){
}
link_message(integer sNum, integer num, string str, key id){
if (num == -2241){
//nPose has sent us notification that we need to do a sequence
//do some initialization before we read the notecard, grab the notecard name to process
iLine = 0;
loopTo = 0;
loadedCard = str;
state isRunning;
}else if (num == 34334){
//just a memory check initiated by nPose notecard. typically used for initial setup
llSay(0,"Memory Used by " + llGetScriptName() + ": " + (string)llGetUsedMemory() + " of " + (string)llGetMemoryLimit()
+ ",Leaving " + (string)llGetFreeMemory() + " memory free.");
}
}
changed(integer change){
if (llGetObjectPrimCount(llGetKey()) == llGetNumberOfPrims()){ //check to see if anyone is still seated
//all are off so do some cleanup and turn off the timer
iLine = 0;
}
}
}
state isRunning{
state_entry(){
//we got here because we need to start a new sequence so read the first line and let'r rip
kQuery = llGetNotecardLine(loadedCard, iLine);
}
link_message(integer sNum, integer num, string str, key id){
if (num == -2241){
//nPose has sent us notification that we need to do a new sequence
//do some initialization before we read the notecard, grab the notecard name to process
iLine = 0;
loopTo = 0;
loadedCard = str;
kQuery = llGetNotecardLine(loadedCard, iLine);
}else if (num == -2240){
//commands sent from nPose to do other stuff
if (str == "Pause") {
//pause command does just that, it pauses the timer and holds the corrent pose
llSetTimerEvent(0.0);
state isPaused;
}else if (str == "Next"){
//next will move to the next sequence
iLine += 1;
kQuery = llGetNotecardLine(loadedCard, iLine);
}else if (str == "Prev"){
//prev moves to the previous line in the notecard
iLine -= 1;
//check bounds of prev clicks and do not let iLine go more than -1
if (iLine <= 0){
iLine = 0;
}
kQuery = llGetNotecardLine(loadedCard, iLine);
}
}else if (num == 35353){
//here is the check to see if nPose wants to move to a normal non-sequenced pose set
if (cardToRun != (string)id){
//if the pose set does not match the one the sequencer is running, stop the timer
llSetTimerEvent(0.0);
state default;
}
}else if (num == 34334){
//just a memory check initiated by nPose notecard. typically used for initial setup
llSay(0,"Memory Used by " + llGetScriptName() + ": " + (string)llGetUsedMemory() + " of " + (string)llGetMemoryLimit()
+ ",Leaving " + (string)llGetFreeMemory() + " memory free.");
}
}
dataserver(key query_id, string data){
if (query_id == kQuery){
if (data == EOF){
llSetTimerEvent(0.0);
}else{
list thisLine = llParseString2List(data,["|"],[]);
posePause = llList2Float(thisLine, 0);
cardToRun = llList2String(thisLine, 1);
if (llList2String(thisLine,0) == "LOOPTO"){
//if it is LOOPTO line in notecard, set our LOOPTO variable to this line number for future use
loopTo = iLine;
iLine += 1; //pass over the LOOPTO line and read the next one instead
kQuery = llGetNotecardLine(loadedCard, iLine);
//check if this notecard line is LOOP
}else if (llList2String(thisLine,0) == "LOOP"){
//we have a LOOP command in this line so it is time to go back to the LOOPTO line number
iLine = loopTo;
if (loopTo > 0){
iLine = loopTo + 1;
}
kQuery = llGetNotecardLine(loadedCard, iLine);
}
if (cardToRun != ""){ //we've sorted out which line to use to fire the next sequence. do it.
llSetTimerEvent(posePause);
if (llSubStringIndex(cardToRun, "BTN:") == 0){
llMessageLinked(LINK_SET,207, cardToRun, NULL_KEY);
}else if (llSubStringIndex(cardToRun, "SET:") == 0){
llMessageLinked(LINK_SET,200, cardToRun, NULL_KEY);
}
}
}
}
}
timer(){
//stop the timer just in case this script is slow so we ensure it only fires when we want it to
llSetTimerEvent(0.0);
//read the next line number
iLine += 1;
kQuery = llGetNotecardLine(loadedCard, iLine);
}
changed(integer change){
if (change & CHANGED_LINK){
if (llGetObjectPrimCount(llGetKey()) == llGetNumberOfPrims()){ //check to see if anyone is still seated
//all are off so do some cleanup and turn off the timer
iLine = 0;
llSetTimerEvent(0.0);
state default;
}
}
}
}
state isPaused{
link_message(integer sNum, integer num, string str, key id){
if (num == -2241){
//nPose has sent us notification that we need to do a new sequence
//do some initialization before we read the notecard, grab the notecard name to process
iLine = 0;
loopTo = 0;
loadedCard = str;
state isRunning;
}else if (num == -2240){
//commands sent from nPose to do other stuff
if (str == "Next"){
//next will move to the next sequence
iLine += 1;
loopToSkipper = 1; //offset for the LOOPTO line to get past it
kQuery = llGetNotecardLine(loadedCard, iLine);
}else if (str == "Prev"){
//prev moves to the previous line in the notecard
iLine -= 1;
loopToSkipper = -1; //offset for the LOOPTO line to get past it
//check bounds of prev clicks and do not let iLine go more than -1
if (iLine <= 0){
iLine = 0;
}
kQuery = llGetNotecardLine(loadedCard, iLine);
}else if (str == "Resume"){
//resume is the anti-pause and will start the paused timer at the current pose
state isRunning;
}
}else if (num == 35353){
//here is the check to see if nPose wants to move to a normal non-sequenced pose set
if (cardToRun != (string)id){
//if the pose set does not match the one the sequencer is running, stop the timer
llSetTimerEvent(0.0);
state default;
}
}else if (num == 34334){
//just a memory check initiated by nPose notecard. typically used for initial setup
llSay(0,"Memory Used by " + llGetScriptName() + ": " + (string)llGetUsedMemory() + " of " + (string)llGetMemoryLimit()
+ ",Leaving " + (string)llGetFreeMemory() + " memory free.");
}
}
dataserver(key query_id, string data){
if (query_id == kQuery){
if (data == EOF){
llSetTimerEvent(0.0);
}else{
list thisLine = llParseString2List(data,["|"],[]);
posePause = llList2Float(thisLine, 0);
cardToRun = llList2String(thisLine, 1);
if (llList2String(thisLine,0) == "LOOPTO"){
//if it is LOOPTO line in notecard, set our LOOPTO variable to this line number for future use
loopTo = iLine;
iLine += loopToSkipper; //pass over the LOOPTO line and read the next one instead
kQuery = llGetNotecardLine(loadedCard, iLine);
//check if this notecard line is LOOP
}else if (llList2String(thisLine,0) == "LOOP"){
//we have a LOOP command in this line so it is time to go back to the LOOPTO line number
iLine = loopTo;
if (loopTo > 0){
iLine = loopTo + 1;
}
kQuery = llGetNotecardLine(loadedCard, iLine);
}
if (cardToRun != ""){ //we've sorted out which line to use to fire the next sequence. do it.
if (llSubStringIndex(cardToRun, "BTN:") == 0){
llMessageLinked(LINK_SET,207, cardToRun, NULL_KEY);
}else if (llSubStringIndex(cardToRun, "SET:") == 0){
llMessageLinked(LINK_SET,200, cardToRun, NULL_KEY);
}
}
}
}
}
changed(integer change){
if (change & CHANGED_LINK){
if (llGetObjectPrimCount(llGetKey()) == llGetNumberOfPrims()){ //check to see if anyone is still seated
//all are off so do some cleanup and turn off the timer
iLine = 0;
llSetTimerEvent(0.0);
state default;
}
}
}
}