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
Maya Advanced_Sculptie_Exporter_From_May  

Advanced_Sculptie_Exporter_From_May

A friend asked me to have a look at some scripts for him that didn't work in OpenSim to export advanced scenes from Maya directly into OpenSim.
Before you go any further please read this page: http://wiki.secondlife.com/wiki/Advance ... _From_Maya
This topic only includes the lsl scripts that are compatible with OpenSim and not the Maya script or instructions, please see the link above for those. Here are the OpenSim compatible scripts only.

I have also added a routine to remove all the left over textures from the prims as the original didn't include that.

Also, as I did not write this script, I will not support it. Please do not ask me for support regarding it; I only made it work in OpenSim

Category: Maya
By : Adelle Fitzgerald
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

the Zip file

Download all files for Advanced_Sculptie_Exporter_From_May
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Advanced_Sculptie_Exporter_From_May_1.lsl
Get file # 2. Advanced_Sculptie_Exporter_From_May_2.lsl
Get file # 3. Advanced_Sculptie_Exporter_From_May_3.lsl
Get file # 4. Advanced_Sculptie_Exporter_From_May_4.lsl
Get file # 5. Advanced_Sculptie_Exporter_From_May_5.lsl
1 // assembled by ../bin/lslcc -I. -I.. -I../.. prim.lsl
2 // by qarl with qLab v0.0.3
3 // Mon Jun 18 19:11:26 PDT 2007
4 //
5 // Fixed for opensim by Adelle Fitzgerald - 5 november 2009
6
7 string parseWord;
8
9
10
11
12 qUserError(string message)
13 {
14 llOwnerSay(message);
15 }
16
17
18
19 __qError(string error, string file, integer line)
20 {
21 llOwnerSay(error + ":" +
22 llGetScriptName() + ":" +
23 file + "(" +
24 (string)line + ")");
25 }
26
27
28 integer __qDebugLevel = 0;
29
30 qDebugSetLevel(integer level)
31 {
32 __qDebugLevel = level;
33 }
34
35
36
37 __qDebug(string message, integer level, string file, integer line)
38 {
39 if(level < __qDebugLevel)
40 __qError("DEBUG: " + message, file, line);
41 }
42
43
44
45
46 list qCommandCreate(string commandName)
47 {
48 list command;
49
50 command = [ commandName ];
51
52 return command;
53 }
54
55
56
57 list qCommandAddSwitch(list command, list switch)
58 {
59 string switchName = llList2String(switch, 0);
60 integer settingCount = llGetListLength(switch) - 1;
61
62 command += [switchName, settingCount];
63
64 if(settingCount > 0)
65 command += llList2List(switch, 1, settingCount);
66
67 return command;
68 }
69
70
71 qCommandUsage(list command)
72 {
73 qUserError("USAGE: " + llList2String(command, 0));
74
75 integer commandLength = llGetListLength(command);
76
77 integer i;
78 for (i = 1; i < commandLength; i) // i incremented below
79 {
80 string output = "";
81
82 string switch = llList2String(command, i);
83 i++;
84 integer settingCount = llList2Integer(command, i);
85 i++;
86
87 output = " " + switch;
88
89 integer j;
90 for (j = 0; j < settingCount; j++)
91 {
92 output = output + " " + llList2String(command, i);
93 i++;
94 }
95
96 qUserError(output);
97 }
98 }
99
100
101
102
103 list qCommandParseText(list command, string text)
104 {
105 integer commandLength = llGetListLength(command);
106
107 list parse = llParseString2List(text, [" "], []);
108 integer parseLength = llGetListLength(parse);
109
110 // make sure this is our command
111 string parseCommand = llList2String(parse, 0);
112 string commandCommand = llList2String(command, 0);
113
114 string objectName = llGetObjectName();
115 string objectKey = (string)llGetKey();
116
117 if((parseCommand != "*") && // wildcard matches all commands
118 (parseCommand != commandCommand) &&
119 (parseCommand != objectName + "/" + commandCommand) &&
120 (parseCommand != objectKey + "/" + commandCommand))
121 return [];
122
123 list switches = [ parseCommand ];;
124
125 integer i;
126 for (i = 1; i < parseLength; i) // i incremented below
127 {
128 parseWord = llList2String(parse, i);
129 i++;
130
131 integer found = 0;
132
133 // scan switch list to see which one we've got:
134 integer j;
135 for (j = 1; (j < commandLength) && (found == 0); j) // j incremented below
136 {
137
138 string switch = llList2String(command, j);
139 j++;
140 integer settingCount = llList2Integer(command, j);
141 j++;
142
143 if(parseWord == switch)
144 {
145 found = 1;
146 switches += [ switch ];
147
148 integer k;
149 for (k = 0; k < settingCount; k++)
150 {
151 if(i >= parseLength)
152 {
153 qUserError("\"" + switch + "\" requires " +
154 (string)settingCount + " options.");
155 qCommandUsage(command);
156 return [];
157 }
158
159 parseWord = llList2String(parse, i);
160 i++;
161
162 string settingType = llList2String(command, j+k);
163
164 if(settingType == "float")
165 switches += [(float) parseWord];
166
167 else if(settingType == "integer")
168 switches += [(integer) parseWord];
169
170 else // assume string
171 switches += [ llUnescapeURL(parseWord) ];
172 }
173 }
174
175 j += settingCount;
176 }
177
178
179 if(!found)
180 {
181 qUserError("\"" + parseWord + "\" not understood.");
182 qCommandUsage(command);
183 return [];
184 }
185 }
186
187
188 return switches;
189 }
190
191 // universal switches
192
193
194 list qCommandAddDebugSwitch(list command)
195 {
196 return qCommandAddSwitch(command, ["-debug", "integer"]);
197 }
198
199 list qCommandAddResetSwitch(list command)
200 {
201 return qCommandAddSwitch(command, ["-reset"]);
202 }
203
204 list qCommandAddDieSwitch(list command)
205 {
206 return qCommandAddSwitch(command, ["-die"]);
207 }
208
209 list qCommandAddHelpSwitch(list command)
210 {
211 if(llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)
212 return qCommandAddSwitch(command, ["-help"]);
213
214 else
215 return command;
216 }
217
218
219 list qCommandAddUniversalSwitches(list command)
220 {
221 command = qCommandAddDebugSwitch(command);
222 command = qCommandAddResetSwitch(command);
223 command = qCommandAddDieSwitch(command);
224 command = qCommandAddHelpSwitch(command);
225
226 return command;
227 }
228
229 integer qCommandExecuteUniversalSwitch(list switches, integer i)
230 {
231 string switch = llList2String(switches, i);
232
233 if(switch == "-debug")
234 {
235 i++;
236 qDebugSetLevel(llList2Integer(switches, i));
237 i++;
238 }
239 else if(switch == "-reset")
240 {
242 i++;
243 }
244 else if(switch == "-die")
245 {
246 llDie();
247 i++;
248 }
249
250 else if(switch == "-help")
251 {
253 "Instruction Manual");
254 i++;
255 }
256
257 return i;
258 }
259
260
261
262
263 vector qGetLocalPosition()
264 {
265 return llGetPos();
266 }
267
268 vector qGetGlobalPosition()
269 {
270 return llGetPos() + llGetRegionCorner();
271 }
272
273 vector qGlobal2LocalPosition(vector global)
274 {
275 return global - llGetRegionCorner();
276 }
277
278 vector qLocal2GlobalPosition(vector local)
279 {
280 return local + llGetRegionCorner();
281 }
282
283 qSetLocalPosition(vector local)
284 {
285 llSetPos(local);
286 }
287
288 qSetGlobalPosition(vector global)
289 {
290 qSetLocalPosition(qGlobal2LocalPosition(global));
291 }
292
293 qGotoGlobalPosition(vector target)
294 {
295 vector position = qGetGlobalPosition();
296
297 integer i;
298 for (i = 0;
299 ((i < 1000) && // no infinite loops, thank you.
300 (llVecDist(target, position) > 0.01));
301 i++)
302 {
303 qSetGlobalPosition(target);
304 position = qGetGlobalPosition();
305 }
306 }
307
308
309
310
311
312
313
314 list primCommand;
315
316 buildPrimCommand()
317 {
318 primCommand = qCommandCreate("prim");
319 primCommand = qCommandAddUniversalSwitches(primCommand);
320
321 primCommand = qCommandAddSwitch(primCommand, ["-setObjectName",
322 "string"]);
323 primCommand = qCommandAddSwitch(primCommand, ["-setObjectDesc",
324 "string"]);
325 primCommand = qCommandAddSwitch(primCommand, ["-setText",
326 "string", "float", "float", "float", "float"]);
327 primCommand = qCommandAddSwitch(primCommand, ["-setPIN",
328 "integer"]);
329 primCommand = qCommandAddSwitch(primCommand, ["-sleep",
330 "integer"]);
331 primCommand = qCommandAddSwitch(primCommand, ["-deleteScript"]);
332
333 }
334
335
336
337 initPrimCommand()
338 {
339 buildPrimCommand();
340
341 llListen(500, "", NULL_KEY, "");
342
343 integer privateChannel = llGetStartParameter();
344 if(privateChannel != 0)
345 llListen(privateChannel, "", NULL_KEY, "");
346 }
347
348
349
350 executePrimCommand(list switches)
351 {
352 integer switchesLength = llGetListLength(switches);
353
354 integer i;
355 for (i = 1; i < switchesLength; i)
356 {
357 string switch = llList2String(switches, i);
358
359 if(switch == "-deleteScript")
360 {
362 i++;
363 }
364
365 else if(switch == "-setObjectName")
366 {
367 llSetObjectName(llList2String(switches, i+1));
368 i+=2;
369 }
370
371 else if(switch == "-setObjectDesc")
372 {
373 llSetObjectDesc(llList2String(switches, i+1));
374 i+=2;
375 }
376
377 else if(switch == "-setText")
378 {
379 llSetText(llList2String(switches, i+1),
380 (< llList2Float(switches, i+2),
381 llList2Float(switches, i+3),
382 llList2Float(switches, i+4) >),
383 llList2Float(switches, i+5));
384 i+=6;
385 }
386
387 else if(switch == "-setPIN")
388 {
390 i+=2;
391 }
392
393 else if(switch == "-sleep")
394 {
395 llSleep(llList2Integer(switches, i+1));
396 i+=2;
397 }
398
399
400 else
401 i = qCommandExecuteUniversalSwitch(switches, i);
402
403 }
404 }
405
406 parsePrimCommand(string message)
407 {
408 list switches = qCommandParseText(primCommand, message);
409
410 if(switches != [])
411 executePrimCommand(switches);
412
413 }
414
415
416 listenPrimCommand(integer channel, string name, key id, string message)
417 {
418 // we only accept commands on the public channel from our owner
419 if((channel == 500) &&
420 (name != llKey2Name(llGetOwner())))
421 return;
422
423 parsePrimCommand(message);
424 }
425
426
427 linkMessagePrimCommand(integer sender, integer num, string message, key id)
428 {
429 parsePrimCommand(message);
430 }
431
432
433 default
434 {
436 {
437 initPrimCommand();
438 }
439
441 {
442 initPrimCommand();
443 }
444
445 listen(integer channel, string name, key id, string message)
446 {
447 listenPrimCommand(channel, name, id, message);
448 }
449
450 link_message(integer sender, integer num, string message, key id)
451 {
452 linkMessagePrimCommand(sender, num, message, id);
453 }
454 }

Advanced_Sculptie_Exporter_From_May


Texture

Category: Maya
By : Adelle Fitzgerald
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

1 // assembled by ../bin/lslcc -I. -I.. -I../.. texture.lsl
2 // by qarl with qLab v0.0.3
3 // Tue Jun 19 13:54:40 PDT 2007
4 //
5 // Fixed for opensim by Adelle Fitzgerald and also added clean up routine to remove all the left over textures - 5 november 2009
6
7
8
9 string parseWord;
10
11
12 qUserError(string message)
13 {
14 llOwnerSay(message);
15 }
16
17
18
19 __qError(string error, string file, integer line)
20 {
21 llOwnerSay(error + ":" +
22 llGetScriptName() + ":" +
23 file + "(" +
24 (string)line + ")");
25 }
26
27
28 integer __qDebugLevel = 0;
29
30 qDebugSetLevel(integer level)
31 {
32 __qDebugLevel = level;
33 }
34
35
36
37 __qDebug(string message, integer level, string file, integer line)
38 {
39 if(level < __qDebugLevel)
40 __qError("DEBUG: " + message, file, line);
41 }
42
43
44
45
46 list qCommandCreate(string commandName)
47 {
48 list command;
49
50 command = [ commandName ];
51
52 return command;
53 }
54
55
56
57 list qCommandAddSwitch(list command, list switch)
58 {
59 string switchName = llList2String(switch, 0);
60 integer settingCount = llGetListLength(switch) - 1;
61
62 command += [switchName, settingCount];
63
64 if(settingCount > 0)
65 command += llList2List(switch, 1, settingCount);
66
67 return command;
68 }
69
70
71 qCommandUsage(list command)
72 {
73 qUserError("USAGE: " + llList2String(command, 0));
74
75 integer commandLength = llGetListLength(command);
76
77 integer i;
78 for (i = 1; i < commandLength; i) // i incremented below
79 {
80 string output = "";
81
82 string switch = llList2String(command, i);
83 i++;
84 integer settingCount = llList2Integer(command, i);
85 i++;
86
87 output = " " + switch;
88
89 integer j;
90 for (j = 0; j < settingCount; j++)
91 {
92 output = output + " " + llList2String(command, i);
93 i++;
94 }
95
96 qUserError(output);
97 }
98 }
99
100
101
102
103 list qCommandParseText(list command, string text)
104 {
105 integer commandLength = llGetListLength(command);
106
107 list parse = llParseString2List(text, [" "], []);
108 integer parseLength = llGetListLength(parse);
109
110 // make sure this is our command
111 string parseCommand = llList2String(parse, 0);
112 string commandCommand = llList2String(command, 0);
113
114 string objectName = llGetObjectName();
115 string objectKey = (string)llGetKey();
116
117 if((parseCommand != "*") && // wildcard matches all commands
118 (parseCommand != commandCommand) &&
119 (parseCommand != objectName + "/" + commandCommand) &&
120 (parseCommand != objectKey + "/" + commandCommand))
121 return [];
122
123 list switches = [ parseCommand ];;
124
125 integer i;
126 for (i = 1; i < parseLength; i) // i incremented below
127 {
128 parseWord = llList2String(parse, i);
129 i++;
130
131 integer found = 0;
132
133 // scan switch list to see which one we've got:
134 integer j;
135 for (j = 1; (j < commandLength) && (found == 0); j) // j incremented below
136 {
137
138 string switch = llList2String(command, j);
139 j++;
140 integer settingCount = llList2Integer(command, j);
141 j++;
142
143 if(parseWord == switch)
144 {
145 found = 1;
146 switches += [ switch ];
147
148 integer k;
149 for (k = 0; k < settingCount; k++)
150 {
151 if(i >= parseLength)
152 {
153 qUserError("\"" + switch + "\" requires " +
154 (string)settingCount + " options.");
155 qCommandUsage(command);
156 return [];
157 }
158
159 parseWord = llList2String(parse, i);
160 i++;
161
162 string settingType = llList2String(command, j+k);
163
164 if(settingType == "float")
165 switches += [(float) parseWord];
166
167 else if(settingType == "integer")
168 switches += [(integer) parseWord];
169
170 else // assume string
171 switches += [ llUnescapeURL(parseWord) ];
172 }
173 }
174
175 j += settingCount;
176 }
177
178
179 if(!found)
180 {
181 qUserError("\"" + parseWord + "\" not understood.");
182 qCommandUsage(command);
183 return [];
184 }
185 }
186
187
188 return switches;
189 }
190
191 // universal switches
192
193
194 list qCommandAddDebugSwitch(list command)
195 {
196 return qCommandAddSwitch(command, ["-debug", "integer"]);
197 }
198
199 list qCommandAddResetSwitch(list command)
200 {
201 return qCommandAddSwitch(command, ["-reset"]);
202 }
203
204 list qCommandAddDieSwitch(list command)
205 {
206 return qCommandAddSwitch(command, ["-die"]);
207 }
208
209 list qCommandAddHelpSwitch(list command)
210 {
211 if(llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)
212 return qCommandAddSwitch(command, ["-help"]);
213
214 else
215 return command;
216 }
217
218
219 list qCommandAddUniversalSwitches(list command)
220 {
221 command = qCommandAddDebugSwitch(command);
222 command = qCommandAddResetSwitch(command);
223 command = qCommandAddDieSwitch(command);
224 command = qCommandAddHelpSwitch(command);
225
226 return command;
227 }
228
229 integer qCommandExecuteUniversalSwitch(list switches, integer i)
230 {
231 string switch = llList2String(switches, i);
232
233 if(switch == "-debug")
234 {
235 i++;
236 qDebugSetLevel(llList2Integer(switches, i));
237 i++;
238 }
239 else if(switch == "-reset")
240 {
242 i++;
243 }
244 else if(switch == "-die")
245 {
246 llDie();
247 i++;
248 }
249
250 else if(switch == "-help")
251 {
253 "Instruction Manual");
254 i++;
255 }
256
257 return i;
258 }
259
260
261
262
263 vector qGetLocalPosition()
264 {
265 return llGetPos();
266 }
267
268 vector qGetGlobalPosition()
269 {
270 return llGetPos() + llGetRegionCorner();
271 }
272
273 vector qGlobal2LocalPosition(vector global)
274 {
275 return global - llGetRegionCorner();
276 }
277
278 vector qLocal2GlobalPosition(vector local)
279 {
280 return local + llGetRegionCorner();
281 }
282
283 qSetLocalPosition(vector local)
284 {
285 llSetPos(local);
286 }
287
288 qSetGlobalPosition(vector global)
289 {
290 qSetLocalPosition(qGlobal2LocalPosition(global));
291 }
292
293 qGotoGlobalPosition(vector target)
294 {
295 vector position = qGetGlobalPosition();
296
297 integer i;
298 for (i = 0;
299 ((i < 1000) && // no infinite loops, thank you.
300 (llVecDist(target, position) > 0.01));
301 i++)
302 {
303 qSetGlobalPosition(target);
304 position = qGetGlobalPosition();
305 }
306 }
307
308
309
310
311
312
313
314 list textureCommand;
315
316 buildTextureCommand()
317 {
318 textureCommand = qCommandCreate("texture");
319 textureCommand = qCommandAddUniversalSwitches(textureCommand);
320
321 textureCommand = qCommandAddSwitch(textureCommand, ["-setColor",
322 "float", "float", "float", "integer"]);
323 textureCommand = qCommandAddSwitch(textureCommand, ["-setAlpha",
324 "float", "integer"]);
325 textureCommand = qCommandAddSwitch(textureCommand, ["-setTexture",
326 "string", "integer"]);
327 textureCommand = qCommandAddSwitch(textureCommand, ["-setTexturePos",
328 "float", "float", "float", "float", "float", "integer"]);
329 textureCommand = qCommandAddSwitch(textureCommand, ["-setFullBright", "integer", "integer" ]);
330 textureCommand = qCommandAddSwitch(textureCommand, ["-sleep",
331 "integer"]);
332 textureCommand = qCommandAddSwitch(textureCommand, ["-deleteScript"]);
333 }
334
335
336
337 initTextureCommand()
338 {
339 buildTextureCommand();
340
341 llListen(500, "", NULL_KEY, "");
342
343 integer privateChannel = llGetStartParameter();
344 if(privateChannel != 0)
345 llListen(privateChannel, "", NULL_KEY, "");
346 }
347
348
349
350 executeTextureCommand(list switches)
351 {
352 integer switchesLength = llGetListLength(switches);
353
354 integer i;
355 for (i = 1; i < switchesLength; i)
356 {
357 string switch = llList2String(switches, i);
358
359 if(switch == "-setColor")
360 {
361 llSetColor(<llList2Float(switches, i+1),
362 llList2Float(switches, i+2),
363 llList2Float(switches, i+3)>,
364 llList2Integer(switches, i+4));
365 i+=5;
366 }
367
368 else if(switch == "-setAlpha")
369 {
370 llSetAlpha(llList2Float(switches, i+1),
371 llList2Integer(switches, i+2));
372 i+=3;
373 }
374
375 else if(switch == "-setTexture")
376 {
377 string texture = llList2String(switches, i+1);
378
379 if(texture == "blank")
380 texture = "5748decc-f629-461c-9a36-a35a221fe21f";
381
382 // if inventory name give, convert to asset id when possible
383 key uuid = llGetInventoryKey(texture);
384 if(uuid != NULL_KEY)
385 texture = (string)uuid;
386
387 llSay(0, "setting texture to: " + texture);
388
389 llSetTexture(texture,
390 llList2Integer(switches, i+2));
391 i+=3;
392 }
393
394 else if(switch == "-setTexturePos")
395 {
396 integer side = llList2Integer(switches, i+6);
397
398 llOffsetTexture(llList2Float(switches, i+1),
399 llList2Float(switches, i+2),
400 side);
401 llRotateTexture(llList2Float(switches, i+3),
402 side);
403 llScaleTexture(llList2Float(switches, i+4),
404 llList2Float(switches, i+5),
405 side);
406
407 i+=7;
408 }
409
410 else if(switch == "-setFullBright")
411 {
412 integer side = llList2Integer(switches, i+1);
413 integer on = llList2Integer(switches, i+2);
414
416
417 i+=3;
418 }
419
420 else if(switch == "-deleteScript")
421 {
423 i++;
424 }
425
426
427 else if(switch == "-sleep")
428 {
429 llSleep(llList2Integer(switches, i+1));
430 i+=2;
431 }
432
433
434 else
435 i = qCommandExecuteUniversalSwitch(switches, i);
436
437 }
438 }
439
440
441 parseTextureCommand(string message)
442 {
443 list switches = qCommandParseText(textureCommand, message);
444
445 if(switches != [])
446 executeTextureCommand(switches);
447
448 }
449
450
451 listenTextureCommand(integer channel, string name, key id, string message)
452 {
453 // we only accept commands on the public channel from our owner
454 if((channel == 500) &&
455 (name != llKey2Name(llGetOwner())))
456 return;
457
458 parseTextureCommand(message);
459 }
460
461
462 linkMessageTextureCommand(integer sender, integer num, string message, key id)
463 {
464 parseTextureCommand(message);
465 }
466
467
468 default
469 {
471 {
472 initTextureCommand();
473 }
474
476 {
477 initTextureCommand();
478 }
479
480 listen(integer channel, string name, key id, string message)
481 {
482 listenTextureCommand(channel, name, id, message);
483 }
484
485 link_message(integer sender, integer num, string message, key id)
486 {
487 linkMessageTextureCommand(sender, num, message, id);
488 }
489 timer()
490 {
491 //Check to make sure all scripts have removed themselves then clean up textures and remove this script
493 {
495 integer i;
496 for (i = 0; i < textureNo; i++)
497 {
499 llRemoveInventory(textureName);
500 llSleep(0.2);
501 }
503 }
504 else
505 {
507 }
508 }
509 }

Advanced_Sculptie_Exporter_From_May

Transform

Category: Maya
By : Adelle Fitzgerald
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

1 // assembled by ../bin/lslcc -I. -I.. -I../.. transform.lsl
2 // by qarl with qLab v0.0.3
3 // Mon Jun 18 19:11:27 PDT 2007
4 //
5 // Fixed for opensim by Adelle Fitzgerald - 5 november 2009
6
7
8
9 string parseWord;
10
11
12 qUserError(string message)
13 {
14 llOwnerSay(message);
15 }
16
17
18
19 __qError(string error, string file, integer line)
20 {
21 llOwnerSay(error + ":" +
22 llGetScriptName() + ":" +
23 file + "(" +
24 (string)line + ")");
25 }
26
27
28 integer __qDebugLevel = 0;
29
30 qDebugSetLevel(integer level)
31 {
32 __qDebugLevel = level;
33 }
34
35
36
37 __qDebug(string message, integer level, string file, integer line)
38 {
39 if(level < __qDebugLevel)
40 __qError("DEBUG: " + message, file, line);
41 }
42
43
44
45
46 list qCommandCreate(string commandName)
47 {
48 list command;
49
50 command = [ commandName ];
51
52 return command;
53 }
54
55
56
57 list qCommandAddSwitch(list command, list switch)
58 {
59 string switchName = llList2String(switch, 0);
60 integer settingCount = llGetListLength(switch) - 1;
61
62 command += [switchName, settingCount];
63
64 if(settingCount > 0)
65 command += llList2List(switch, 1, settingCount);
66
67 return command;
68 }
69
70
71 qCommandUsage(list command)
72 {
73 qUserError("USAGE: " + llList2String(command, 0));
74
75 integer commandLength = llGetListLength(command);
76
77 integer i;
78 for (i = 1; i < commandLength; i) // i incremented below
79 {
80 string output = "";
81
82 string switch = llList2String(command, i);
83 i++;
84 integer settingCount = llList2Integer(command, i);
85 i++;
86
87 output = " " + switch;
88
89 integer j;
90 for (j = 0; j < settingCount; j++)
91 {
92 output = output + " " + llList2String(command, i);
93 i++;
94 }
95
96 qUserError(output);
97 }
98 }
99
100
101
102
103 list qCommandParseText(list command, string text)
104 {
105 integer commandLength = llGetListLength(command);
106
107 list parse = llParseString2List(text, [" "], []);
108 integer parseLength = llGetListLength(parse);
109
110 // make sure this is our command
111 string parseCommand = llList2String(parse, 0);
112 string commandCommand = llList2String(command, 0);
113
114 string objectName = llGetObjectName();
115 string objectKey = (string)llGetKey();
116
117 if((parseCommand != "*") && // wildcard matches all commands
118 (parseCommand != commandCommand) &&
119 (parseCommand != objectName + "/" + commandCommand) &&
120 (parseCommand != objectKey + "/" + commandCommand))
121 return [];
122
123 list switches = [ parseCommand ];;
124
125 integer i;
126 for (i = 1; i < parseLength; i) // i incremented below
127 {
128 parseWord = llList2String(parse, i);
129 i++;
130
131 integer found = 0;
132
133 // scan switch list to see which one we've got:
134 integer j;
135 for (j = 1; (j < commandLength) && (found == 0); j) // j incremented below
136 {
137
138 string switch = llList2String(command, j);
139 j++;
140 integer settingCount = llList2Integer(command, j);
141 j++;
142
143 if(parseWord == switch)
144 {
145 found = 1;
146 switches += [ switch ];
147
148 integer k;
149 for (k = 0; k < settingCount; k++)
150 {
151 if(i >= parseLength)
152 {
153 qUserError("\"" + switch + "\" requires " +
154 (string)settingCount + " options.");
155 qCommandUsage(command);
156 return [];
157 }
158
159 parseWord = llList2String(parse, i);
160 i++;
161
162 string settingType = llList2String(command, j+k);
163
164 if(settingType == "float")
165 switches += [(float) parseWord];
166
167 else if(settingType == "integer")
168 switches += [(integer) parseWord];
169
170 else // assume string
171 switches += [ llUnescapeURL(parseWord) ];
172 }
173 }
174
175 j += settingCount;
176 }
177
178
179 if(!found)
180 {
181 qUserError("\"" + parseWord + "\" not understood.");
182 qCommandUsage(command);
183 return [];
184 }
185 }
186
187
188 return switches;
189 }
190
191 // universal switches
192
193
194 list qCommandAddDebugSwitch(list command)
195 {
196 return qCommandAddSwitch(command, ["-debug", "integer"]);
197 }
198
199 list qCommandAddResetSwitch(list command)
200 {
201 return qCommandAddSwitch(command, ["-reset"]);
202 }
203
204 list qCommandAddDieSwitch(list command)
205 {
206 return qCommandAddSwitch(command, ["-die"]);
207 }
208
209 list qCommandAddHelpSwitch(list command)
210 {
211 if(llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)
212 return qCommandAddSwitch(command, ["-help"]);
213
214 else
215 return command;
216 }
217
218
219 list qCommandAddUniversalSwitches(list command)
220 {
221 command = qCommandAddDebugSwitch(command);
222 command = qCommandAddResetSwitch(command);
223 command = qCommandAddDieSwitch(command);
224 command = qCommandAddHelpSwitch(command);
225
226 return command;
227 }
228
229 integer qCommandExecuteUniversalSwitch(list switches, integer i)
230 {
231 string switch = llList2String(switches, i);
232
233 if(switch == "-debug")
234 {
235 i++;
236 qDebugSetLevel(llList2Integer(switches, i));
237 i++;
238 }
239 else if(switch == "-reset")
240 {
242 i++;
243 }
244 else if(switch == "-die")
245 {
246 llDie();
247 i++;
248 }
249
250 else if(switch == "-help")
251 {
253 "Instruction Manual");
254 i++;
255 }
256
257 return i;
258 }
259
260
261
262
263 vector qGetLocalPosition()
264 {
265 return llGetPos();
266 }
267
268 vector qGetGlobalPosition()
269 {
270 return llGetPos() + llGetRegionCorner();
271 }
272
273 vector qGlobal2LocalPosition(vector global)
274 {
275 return global - llGetRegionCorner();
276 }
277
278 vector qLocal2GlobalPosition(vector local)
279 {
280 return local + llGetRegionCorner();
281 }
282
283 qSetLocalPosition(vector local)
284 {
285 llSetPos(local);
286 }
287
288 qSetGlobalPosition(vector global)
289 {
290 qSetLocalPosition(qGlobal2LocalPosition(global));
291 }
292
293 qGotoGlobalPosition(vector target)
294 {
295 vector position = qGetGlobalPosition();
296
297 integer i;
298 for (i = 0;
299 ((i < 1000) && // no infinite loops, thank you.
300 (llVecDist(target, position) > 0.01));
301 i++)
302 {
303 qSetGlobalPosition(target);
304 position = qGetGlobalPosition();
305 }
306 }
307
308
309
310
311
312
313
314 list transformCommand;
315
316 buildTransformCommand()
317 {
318 transformCommand = qCommandCreate("transform");
319 transformCommand = qCommandAddUniversalSwitches(transformCommand);
320
321 transformCommand = qCommandAddSwitch(transformCommand, ["-setPos",
322 "float", "float", "float"]);
323 transformCommand = qCommandAddSwitch(transformCommand, ["-setGlobalPos",
324 "float", "float", "float"]);
325 transformCommand = qCommandAddSwitch(transformCommand, ["-setRelativePos",
326 "float", "float", "float"]);
327 transformCommand = qCommandAddSwitch(transformCommand, ["-setScale",
328 "float", "float", "float"]);
329 transformCommand = qCommandAddSwitch(transformCommand, ["-setRot",
330 "float", "float", "float"]);
331
332 transformCommand = qCommandAddSwitch(transformCommand, ["-gotoGlobalPos",
333 "float", "float", "float"]);
334 transformCommand = qCommandAddSwitch(transformCommand, ["-gotoRelativePos",
335 "float", "float", "float"]);
336 transformCommand = qCommandAddSwitch(transformCommand, ["-gotoSim",
337 "integer", "integer"]);
338 transformCommand = qCommandAddSwitch(transformCommand, ["-sleep",
339 "integer"]);
340 transformCommand = qCommandAddSwitch(transformCommand, ["-deleteScript"]);
341 }
342
343
344
345 initTransformCommand()
346 {
347 buildTransformCommand();
348
349 llListen(500, "", NULL_KEY, "");
350
351 integer privateChannel = llGetStartParameter();
352 if(privateChannel != 0)
353 llListen(privateChannel, "", NULL_KEY, "");
354 }
355
356
357
358 executeTransformCommand(list switches)
359 {
360 integer switchesLength = llGetListLength(switches);
361
362 integer i;
363 for (i = 1; i < switchesLength; i)
364 {
365 string switch = llList2String(switches, i);
366
367 if(switch == "-setPos")
368 {
369 llSetPos(<llList2Float(switches, i+1),
370 llList2Float(switches, i+2),
371 llList2Float(switches, i+3)>);
372 i+=4;
373 }
374 else if(switch == "-setGlobalPos")
375 {
376 qSetGlobalPosition(<llList2Float(switches, i+1),
377 llList2Float(switches, i+2),
378 llList2Float(switches, i+3)>);
379 i+=4;
380 }
381 else if(switch == "-setRelativePos")
382 {
383 vector position = qGetGlobalPosition();
384
385 qSetGlobalPosition(position + (<llList2Float(switches, i+1),
386 llList2Float(switches, i+2),
387 llList2Float(switches, i+3)>));
388 i+=4;
389 }
390 else if(switch == "-setScale")
391 {
392 llSetScale(<llList2Float(switches, i+1),
393 llList2Float(switches, i+2),
394 llList2Float(switches, i+3)>);
395 i+=4;
396 }
397 else if(switch == "-setRot")
398 {
399 llSetRot(llEuler2Rot(<llList2Float(switches, i+1),
400 llList2Float(switches, i+2),
401 llList2Float(switches, i+3)>));
402 i+=4;
403 }
404
405 else if(switch == "-deleteScript")
406 {
408 i++;
409 }
410
411
412 else if(switch == "-sleep")
413 {
414 llSleep(llList2Integer(switches, i+1));
415 i+=2;
416 }
417
418 else if(switch == "-gotoSim")
419 {
420 vector position = qGetGlobalPosition();
421 position.x = llList2Float(switches, i+1) * 256 + 128;
422 position.y = llList2Float(switches, i+2) * 256 + 128;
423 qGotoGlobalPosition(position);
424
425 i+=3;
426 }
427 else if(switch == "-gotoGlobalPos")
428 {
429 qGotoGlobalPosition(<llList2Float(switches, i+1),
430 llList2Float(switches, i+2),
431 llList2Float(switches, i+3)>);
432 i+=4;
433 }
434 else if(switch == "-gotoRelativePos")
435 {
436 vector position = qGetGlobalPosition();
437 qGotoGlobalPosition(position + (<llList2Float(switches, i+1),
438 llList2Float(switches, i+2),
439 llList2Float(switches, i+3)>));
440 i+=4;
441 }
442
443 else if(switch == "-gotoSim")
444 {
445 vector position = qGetGlobalPosition();
446 position.x = llList2Float(switches, i+1) * 256 + 128;
447 position.y = llList2Float(switches, i+2) * 256 + 128;
448 qGotoGlobalPosition(position);
449
450 i+=3;
451 }
452
453
454
455 else
456 i = qCommandExecuteUniversalSwitch(switches, i);
457
458 }
459 }
460
461
462 parseTransformCommand(string message)
463 {
464 list switches = qCommandParseText(transformCommand, message);
465
466 if(switches != [])
467 executeTransformCommand(switches);
468
469 }
470
471
472 listenTransformCommand(integer channel, string name, key id, string message)
473 {
474 // we only accept commands on the public channel from our owner
475 if((channel == 500) &&
476 (name != llKey2Name(llGetOwner())))
477 return;
478
479 parseTransformCommand(message);
480 }
481
482
483 linkMessageTransformCommand(integer sender, integer num, string message, key id)
484 {
485 parseTransformCommand(message);
486 }
487
488
489 default
490 {
492 {
493 initTransformCommand();
494 }
495
497 {
498 initTransformCommand();
499 }
500
501 listen(integer channel, string name, key id, string message)
502 {
503 listenTransformCommand(channel, name, id, message);
504 }
505
506 link_message(integer sender, integer num, string message, key id)
507 {
508 linkMessageTransformCommand(sender, num, message, id);
509 }
510 }

Advanced_Sculptie_Exporter_From_May

Advanced_Sculptie_Exporter_From_May

Category: Maya
By : Adelle Fitzgerald
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

1 n/a

Advanced_Sculptie_Exporter_From_May

PrimScript

Category: Maya
By : Adelle Fitzgerald
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

1 // assembled by ../bin/lslcc -I. -I.. -I../.. primscript.lsl
2 // by qarl with qLab v0.0.3
3 // Tue Jun 19 09:27:34 PDT 2007
4 //
5 // Fixed for opensim by Adelle Fitzgerald - 5 november 2009
6
7
8 string parseWord;
9
10
11 qUserError(string message)
12 {
13 llOwnerSay(message);
14 }
15
16
17
18
19 __qError(string error, string file, integer line)
20 {
21 llOwnerSay(error + ":" +
22 llGetScriptName() + ":" +
23 file + "(" +
24 (string)line + ")");
25 }
26
27
28 integer __qDebugLevel = 0;
29
30 qDebugSetLevel(integer level)
31 {
32 __qDebugLevel = level;
33 }
34
35
36
37 __qDebug(string message, integer level, string file, integer line)
38 {
39 if(level < __qDebugLevel)
40 __qError("DEBUG: " + message, file, line);
41 }
42
43
44
45
46
47 list qCommandCreate(string commandName)
48 {
49 list command;
50
51 command = [ commandName ];
52
53 return command;
54 }
55
56
57
58 list qCommandAddSwitch(list command, list switch)
59 {
60 string switchName = llList2String(switch, 0);
61 integer settingCount = llGetListLength(switch) - 1;
62
63 command += [switchName, settingCount];
64
65 if(settingCount > 0)
66 command += llList2List(switch, 1, settingCount);
67
68 return command;
69 }
70
71
72 qCommandUsage(list command)
73 {
74 qUserError("USAGE: " + llList2String(command, 0));
75
76 integer commandLength = llGetListLength(command);
77
78 integer i;
79 for (i = 1; i < commandLength; i) // i incremented below
80 {
81 string output = "";
82
83 string switch = llList2String(command, i);
84 i++;
85 integer settingCount = llList2Integer(command, i);
86 i++;
87
88 output = " " + switch;
89
90 integer j;
91 for (j = 0; j < settingCount; j++)
92 {
93 output = output + " " + llList2String(command, i);
94 i++;
95 }
96
97 qUserError(output);
98 }
99 }
100
101
102
103
104 list qCommandParseText(list command, string text)
105 {
106 integer commandLength = llGetListLength(command);
107
108 list parse = llParseString2List(text, [" "], []);
109 integer parseLength = llGetListLength(parse);
110
111 // make sure this is our command
112 string parseCommand = llList2String(parse, 0);
113 string commandCommand = llList2String(command, 0);
114
115 string objectName = llGetObjectName();
116 string objectKey = (string)llGetKey();
117
118 if((parseCommand != "*") && // wildcard matches all commands
119 (parseCommand != commandCommand) &&
120 (parseCommand != objectName + "/" + commandCommand) &&
121 (parseCommand != objectKey + "/" + commandCommand))
122 return [];
123
124 list switches = [ parseCommand ];;
125
126 integer i;
127 for (i = 1; i < parseLength; i) // i incremented below
128 {
129 parseWord = llList2String(parse, i);
130 i++;
131
132 integer found = 0;
133
134 // scan switch list to see which one we've got:
135 integer j;
136 for (j = 1; (j < commandLength) && (found == 0); j) // j incremented below
137 {
138
139 string switch = llList2String(command, j);
140 j++;
141 integer settingCount = llList2Integer(command, j);
142 j++;
143
144 if(parseWord == switch)
145 {
146 found = 1;
147 switches += [ switch ];
148
149 integer k;
150 for (k = 0; k < settingCount; k++)
151 {
152 if(i >= parseLength)
153 {
154 qUserError("\"" + switch + "\" requires " +
155 (string)settingCount + " options.");
156 qCommandUsage(command);
157 return [];
158 }
159
160 parseWord = llList2String(parse, i);
161 i++;
162
163 string settingType = llList2String(command, j+k);
164
165 if(settingType == "float")
166 switches += [(float) parseWord];
167
168 else if(settingType == "integer")
169 switches += [(integer) parseWord];
170
171 else // assume string
172 switches += [ llUnescapeURL(parseWord) ];
173 }
174 }
175
176 j += settingCount;
177 }
178
179
180 if(!found)
181 {
182 qUserError("\"" + parseWord + "\" not understood.");
183 qCommandUsage(command);
184 return [];
185 }
186 }
187
188
189 return switches;
190 }
191
192 // universal switches
193
194
195 list qCommandAddDebugSwitch(list command)
196 {
197 return qCommandAddSwitch(command, ["-debug", "integer"]);
198 }
199
200 list qCommandAddResetSwitch(list command)
201 {
202 return qCommandAddSwitch(command, ["-reset"]);
203 }
204
205 list qCommandAddDieSwitch(list command)
206 {
207 return qCommandAddSwitch(command, ["-die"]);
208 }
209
210 list qCommandAddHelpSwitch(list command)
211 {
212 if(llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)
213 return qCommandAddSwitch(command, ["-help"]);
214
215 else
216 return command;
217 }
218
219
220 list qCommandAddUniversalSwitches(list command)
221 {
222 command = qCommandAddDebugSwitch(command);
223 command = qCommandAddResetSwitch(command);
224 command = qCommandAddDieSwitch(command);
225 command = qCommandAddHelpSwitch(command);
226
227 return command;
228 }
229
230 integer qCommandExecuteUniversalSwitch(list switches, integer i)
231 {
232 string switch = llList2String(switches, i);
233
234 if(switch == "-debug")
235 {
236 i++;
237 qDebugSetLevel(llList2Integer(switches, i));
238 i++;
239 }
240 else if(switch == "-reset")
241 {
243 i++;
244 }
245 else if(switch == "-die")
246 {
247 llDie();
248 i++;
249 }
250
251 else if(switch == "-help")
252 {
254 "Instruction Manual");
255 i++;
256 }
257
258 return i;
259 }
260
261
262
263
264 // should make most of these #defines - to take advantage of pseudo polymorphism
265
266
267 float qMin(float a, float b)
268 {
269 if(a < b)
270 return a;
271 else
272 return b;
273 }
274
275 float qMax(float a, float b)
276 {
277 if(a > b)
278 return a;
279 else
280 return b;
281 }
282
283
284 float qClamp(float min, float max, float value)
285 {
286 if(value < min)
287 return min;
288 if(value > max)
289 return max;
290
291 return value;
292 }
293
294
295
296 float qScale(float origMin, float origMax,
297 float newMin, float newMax,
298 float value)
299 {
300 float x = (value - origMin)/(origMax - origMin);
301
302 return newMin + x * (newMax - newMin);
303 }
304
305
306
307 float qSmoothstep (float edge0, float edge1, float x)
308 {
309 if(x < edge0)
310 return 0;
311
312 if(x >= edge1)
313 return 1;
314
315 x = (x - edge0) / (edge1 - edge0);
316
317 return x * x * (3.0 - 2.0 * x);
318 }
319
320
321 float qMod(float value, float divisor)
322 {
323 integer m = llFloor(value / divisor);
324
325 return value - m * divisor;
326 }
327
328 float qRandom(float min, float max)
329 {
330 return llFrand(max - min) + min;
331 }
332
333
334
335
336 // computes bspline index - for either closed (periodic) or open bsplines.
337 integer qSplineIndex(integer index, integer length, integer closed)
338 {
339 if(closed)
340 return (integer) qMod(index, length);
341
342 if(index > length - 1)
343 return length - 1;
344
345 if(index < 0)
346 return 0;
347
348 return index;
349 }
350
351 // vector spline function - takes a list of
352 // vectors and creates a spline over
353 // range [0..llGetListLength(vectors)] (uniform
354
355
356 vector qSplineV(list vectors, float value, integer closed)
357 {
358 float length = llGetListLength(vectors);
359
360 float floor = (float)llFloor(value);
361 float remains = value - floor;
362
363 integer i1 = qSplineIndex((integer)(floor - 1.0), (integer)length, closed);
364 integer i2 = qSplineIndex((integer)(floor + 0.0), (integer)length, closed);
365 integer i3 = qSplineIndex((integer)(floor + 1.0), (integer)length, closed);
366 integer i4 = qSplineIndex((integer)(floor + 2.0), (integer)length, closed);
367
368 vector v1 = llList2Vector(vectors, i1);
369 vector v2 = llList2Vector(vectors, i2);
370 vector v3 = llList2Vector(vectors, i3);
371 vector v4 = llList2Vector(vectors, i4);
372
373 // weights derived from bspline matrix - [Foley1990, p. 493]
374 float t = remains;
375 float t2 = t * remains;
376 float t3 = t2 * remains;
377
378 float w1 = -t3 + (3.0 * t2) - (3.0 * t) + 1.0;
379 float w2 = (3.0 * t3) - (6.0 * t2) + 4.0;
380 float w3 = (-3.0 * t3) + (3.0 * t2) + (3.0 * t) + 1.0;
381 float w4 = t3;
382
383
384 vector p = ( (w1 * v1) + (w2 * v2) + (w3 * v3) + (w4 * v4) ) / 6.0;
385
386 return p;
387 }
388
389
390 // calculate approximate length of spline by stepping in segments.
391 // (you know, i bet this has a closed form. too bad i'm too lazy/stupid to derive it.)
392 float qSplineVLength(list vectors, float v1, float v2, integer segments, integer closed)
393 {
394 float length = 0;
395
396 float segmentDelta = (v2 - v1) / segments;
397
398 integer i;
399 for (i = 0; i < segments; i++)
400 {
401 float s1 = v1 + segmentDelta * i;
402 float s2 = s1 + segmentDelta;
403
404 vector p1 = qSplineV(vectors, s1, closed);
405 vector p2 = qSplineV(vectors, s2, closed);
406
407 length += llVecDist(p1, p2);
408 }
409
410 return length;
411 }
412
413
414
415
416
417 rotation qRotationScale(float a, rotation r)
418 {
419 rotation s;
420
421 s.x = r.x * a;
422 s.y = r.y * a;
423 s.z = r.z * a;
424 s.s = r.s * a;
425
426 return s;
427 }
428
429
430
431 rotation qRotationMix(rotation a, rotation b, float t)
432 {
433 float o = llAngleBetween(a, b) / 2.0;
434
435 if(llFabs(llSin(o)) < 0.001) // too close!
436 return a;
437
438 if(o > PI/2.0)
439 a = (a - a); // take shortest path, please
440
441 rotation c = (qRotationScale(llSin((1.0 - t) * o), a) +
442 qRotationScale(llSin(t * o), b));
443
444 c = qRotationScale(1.0 / llSin(o), c);
445
446 return c;
447 }
448
449
450 string qFloat2String(float value, integer precision)
451 {
452 integer base = llFloor(value);
453 float remainder = value - base;
454
455 string valueStr = (string) base;
456
457 if(remainder != 0)
458 {
459 string remainderStr = (string) remainder;
460 valueStr += llGetSubString(remainderStr, 1, precision + 1);
461 }
462
463 return valueStr;
464 }
465
466
467 string qVector2String(vector value, integer precision)
468 {
469
470 return ("< " +
471 qFloat2String(value.x, precision) + ", " +
472 qFloat2String(value.y, precision) + ", " +
473 qFloat2String(value.z, precision) + " >");
474
475 }
476
477
478
479 list __qDynaPrims;
480 float __qDynaRadius = 0;
481 integer __qDynaCount = 10;
482 vector __qDynaOrigin;
483
484
485 qDynaSetOrigin(vector o)
486 {
487 __qDynaOrigin = o;
488 }
489
490 qDynaSetRadius(float r)
491 {
492 __qDynaRadius = r;
493 }
494
495 qDynaSetCount(integer c)
496 {
497 __qDynaCount = c;
498 }
499
500 integer qDynaRez()
501 {
502 while(llGetListLength(__qDynaPrims) < __qDynaCount)
503 {
504 integer com = (integer)qRandom(10000, 10000000);
505
506 vector place = (__qDynaOrigin +
507 __qDynaRadius * llVecNorm(<llFrand(2.0) - 1,
508 llFrand(2.0) - 1,
509 llFrand(2.0) - 1>));
510
511 llRezObject("qDynaPrim", llGetPos() + place,
512 <0,0,0>, ZERO_ROTATION, com);
513
514 // llSleep(1);
515
516 __qDynaPrims = __qDynaPrims + [ com ];
517
518 }
519
520 integer front = llList2Integer(__qDynaPrims, 0);
521
522 __qDynaPrims = llDeleteSubList(__qDynaPrims, 0, 0);
523
524 return front;
525 }
526
527
528 qDynaCleanup()
529 {
530 llSleep(10);
531 while(llGetListLength(__qDynaPrims) > 0)
532 {
533 integer com = llList2Integer(__qDynaPrims, 0);
534 llSay(com, "prim -die");
535 __qDynaPrims = llDeleteSubList(__qDynaPrims, 0, 0);
536 }
537 }
538
539
540
541 list command;
542 key scriptKey;
543 integer scriptLineNumber;
544 integer scriptRunning;
545 integer scriptCurrentPrim;
546
547
548
549
550 executeScriptLine(string line)
551 {
552 __qDebug("executeScriptLine: " + line, 10, "primscript.lsl", 19);
553 list words = llParseString2List(line, [" "], []);
554
555 if((llGetListLength(words) == 1) &&
556 (llList2String(words, 0) == "newPrim"))
557 scriptCurrentPrim = qDynaRez();
558
559 else
560 llSay(scriptCurrentPrim, line);
561 }
562
563
564 startScript(key script)
565 {
566 __qDebug("startScript: " + (string)script, 5, "primscript.lsl", 33);
567 scriptRunning = 1;
568 scriptKey = script;
569 scriptLineNumber = 0;
570
571 llGetNotecardLine(scriptKey, scriptLineNumber);
572 }
573
574
575 endScript()
576 {
577 __qDebug("endScript", 5, "primscript.lsl", 44);
578 scriptRunning = 0;
579 qDynaCleanup();
580 }
581
582
583
584 buildCommand()
585 {
586 command = qCommandCreate("primscript");
587 command = qCommandAddSwitch(command, ["-script", "string"]);
588 command = qCommandAddUniversalSwitches(command);
589 }
590
591
592 initCommand()
593 {
594 buildCommand();
595
596 llListen(500, "", NULL_KEY, "");
597 }
598
599
600
601 executeCommand(list switches)
602 {
603 integer switchesLength = llGetListLength(switches);
604
605 integer i;
606 for (i = 1; i < switchesLength; i)
607 {
608 string switch = llList2String(switches, i);
609
610 if(switch == "-script")
611 {
612 startScript((key)llList2String(switches, i+1));
613 i += 2;
614 }
615 else
616 i = qCommandExecuteUniversalSwitch(switches, i);
617
618 }
619 }
620
621
622 listenCommand(integer channel, string name, key id, string message)
623 {
624 // we only accept commands from our owner
625 if(id != llGetOwner())
626 return;
627
628 list switches = qCommandParseText(command, message);
629
630 if(switches != [])
631 executeCommand(switches);
632 }
633
634
635
636 default
637 {
639 {
640 scriptRunning = 0;
641 initCommand();
642 }
643
644 dataserver(key id, string data)
645 {
646 if(data != EOF)
647 {
648 executeScriptLine(data);
649
650 scriptLineNumber++;
651 llGetNotecardLine(scriptKey, scriptLineNumber);
652 }
653 else
654 endScript();
655 }
656
657
658 listen(integer channel, string name, key id, string message)
659 {
660 if(!scriptRunning)
661 listenCommand(channel, name, id, message);
662 }
663
664 }

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