Home |
Add a script
|
||
|---|---|---|---|
| Category: | Contributor: | Description | |
| Maya | Adelle Fitzgerald | Advanced Sculptie Exporter From Maya (fixed for OpenSim) | |
Export advanced scenes from Maya directly into OpenSim
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
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
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 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 38 { 39 if (level < __qDebugLevel) 40 __qError("DEBUG: " + message, file, line); 41 } 42 43 44 45 47 { 48 list command; 49 50 command = [ commandName ]; 51 52 return command; 53 } 54 55 56 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 104 {105 integer commandLength = llGetListLength(command);106 107 list parse = llParseString2List(text, [" "], []);108 integer parseLength = llGetListLength(parse);109 110 // make sure this is our command111 string parseCommand = llList2String(parse, 0);112 string commandCommand = llList2String(command, 0);113 114 string objectName = llGetObjectName();116 117 if ((parseCommand != "*") && // wildcard matches all commands118 (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 below127 {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 below136 {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 string171 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 switches192 193 195 {196 return qCommandAddSwitch(command, ["-debug", "integer"]);197 }198 200 {201 return qCommandAddSwitch(command, ["-reset"]);202 }203 205 {206 return qCommandAddSwitch(command, ["-die"]);207 }208 210 {211 if (llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)212 return qCommandAddSwitch(command, ["-help"]);213 214 else215 return command;216 }217 218 220 {221 command = qCommandAddDebugSwitch(command);222 command = qCommandAddResetSwitch(command);223 command = qCommandAddDieSwitch(command);224 command = qCommandAddHelpSwitch(command);225 226 return command;227 }228 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 {241 llResetScript();242 i++;243 }244 else if (switch == "-die")245 {246 llDie();247 i++;248 }249 250 else if (switch == "-help")251 {252 llGiveInventory(llGetOwner(), 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 274 {275 return global - llGetRegionCorner();276 }277 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 342 343 integer privateChannel = llGetStartParameter();344 if (privateChannel != 0)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 {361 llRemoveInventory(llGetScriptName());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 {389 llSetRemoteScriptAccessPin(llList2Integer(switches, i+1));390 i+=2;391 }392 393 else if (switch == "-sleep")394 {395 llSleep(llList2Integer(switches, i+1));396 i+=2;397 }398 399 400 else401 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 417 {418 // we only accept commands on the public channel from our owner419 if ((channel == 500) &&420 (name != llKey2Name(llGetOwner())))421 return;422 423 parsePrimCommand(message);424 }425 426 428 {429 parsePrimCommand(message);430 }431 432 433 default434 {435 state_entry()436 {437 initPrimCommand();438 }439 441 {442 initPrimCommand();443 }444 446 {447 listenPrimCommand(channel, name, id, message);448 }449 451 {452 linkMessagePrimCommand(sender, num, message, id);453 }454 }
Texture
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
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 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 38 { 39 if (level < __qDebugLevel) 40 __qError("DEBUG: " + message, file, line); 41 } 42 43 44 45 47 { 48 list command; 49 50 command = [ commandName ]; 51 52 return command; 53 } 54 55 56 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 104 {105 integer commandLength = llGetListLength(command);106 107 list parse = llParseString2List(text, [" "], []);108 integer parseLength = llGetListLength(parse);109 110 // make sure this is our command111 string parseCommand = llList2String(parse, 0);112 string commandCommand = llList2String(command, 0);113 114 string objectName = llGetObjectName();116 117 if ((parseCommand != "*") && // wildcard matches all commands118 (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 below127 {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 below136 {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 string171 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 switches192 193 195 {196 return qCommandAddSwitch(command, ["-debug", "integer"]);197 }198 200 {201 return qCommandAddSwitch(command, ["-reset"]);202 }203 205 {206 return qCommandAddSwitch(command, ["-die"]);207 }208 210 {211 if (llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)212 return qCommandAddSwitch(command, ["-help"]);213 214 else215 return command;216 }217 218 220 {221 command = qCommandAddDebugSwitch(command);222 command = qCommandAddResetSwitch(command);223 command = qCommandAddDieSwitch(command);224 command = qCommandAddHelpSwitch(command);225 226 return command;227 }228 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 {241 llResetScript();242 i++;243 }244 else if (switch == "-die")245 {246 llDie();247 i++;248 }249 250 else if (switch == "-help")251 {252 llGiveInventory(llGetOwner(), 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 274 {275 return global - llGetRegionCorner();276 }277 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 342 343 integer privateChannel = llGetStartParameter();344 if (privateChannel != 0)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 possible383 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 415 llSetPrimitiveParams([PRIM_FULLBRIGHT, side, on]);416 417 i+=3;418 }419 420 else if (switch == "-deleteScript")421 {422 llSetTimerEvent(1);423 i++;424 }425 426 427 else if (switch == "-sleep")428 {429 llSleep(llList2Integer(switches, i+1));430 i+=2;431 }432 433 434 else435 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 452 {453 // we only accept commands on the public channel from our owner454 if ((channel == 500) &&455 (name != llKey2Name(llGetOwner())))456 return;457 458 parseTextureCommand(message);459 }460 461 463 {464 parseTextureCommand(message);465 }466 467 468 default469 {470 state_entry()471 {472 initTextureCommand();473 }474 476 {477 initTextureCommand();478 }479 481 {482 listenTextureCommand(channel, name, id, message);483 }484 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 script492 if (llGetInventoryNumber(INVENTORY_SCRIPT) == 1)493 {495 integer i;496 for (i = 0; i < textureNo; i++)497 {499 llRemoveInventory(textureName);500 llSleep(0.2);501 }502 llRemoveInventory(llGetScriptName());503 }504 else505 {506 llSetTimerEvent(1);507 }508 } 509 }
Transform
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
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 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 38 { 39 if (level < __qDebugLevel) 40 __qError("DEBUG: " + message, file, line); 41 } 42 43 44 45 47 { 48 list command; 49 50 command = [ commandName ]; 51 52 return command; 53 } 54 55 56 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 104 {105 integer commandLength = llGetListLength(command);106 107 list parse = llParseString2List(text, [" "], []);108 integer parseLength = llGetListLength(parse);109 110 // make sure this is our command111 string parseCommand = llList2String(parse, 0);112 string commandCommand = llList2String(command, 0);113 114 string objectName = llGetObjectName();116 117 if ((parseCommand != "*") && // wildcard matches all commands118 (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 below127 {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 below136 {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 string171 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 switches192 193 195 {196 return qCommandAddSwitch(command, ["-debug", "integer"]);197 }198 200 {201 return qCommandAddSwitch(command, ["-reset"]);202 }203 205 {206 return qCommandAddSwitch(command, ["-die"]);207 }208 210 {211 if (llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)212 return qCommandAddSwitch(command, ["-help"]);213 214 else215 return command;216 }217 218 220 {221 command = qCommandAddDebugSwitch(command);222 command = qCommandAddResetSwitch(command);223 command = qCommandAddDieSwitch(command);224 command = qCommandAddHelpSwitch(command);225 226 return command;227 }228 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 {241 llResetScript();242 i++;243 }244 else if (switch == "-die")245 {246 llDie();247 i++;248 }249 250 else if (switch == "-help")251 {252 llGiveInventory(llGetOwner(), 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 274 {275 return global - llGetRegionCorner();276 }277 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 350 351 integer privateChannel = llGetStartParameter();352 if (privateChannel != 0)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 {400 llList2Float(switches, i+2),401 llList2Float(switches, i+3)>));402 i+=4;403 }404 405 else if (switch == "-deleteScript")406 {407 llRemoveInventory(llGetScriptName());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 else456 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 473 {474 // we only accept commands on the public channel from our owner475 if ((channel == 500) &&476 (name != llKey2Name(llGetOwner())))477 return;478 479 parseTransformCommand(message);480 }481 482 484 {485 parseTransformCommand(message);486 }487 488 489 default490 {491 state_entry()492 {493 initTransformCommand();494 }495 497 {498 initTransformCommand();499 }500 502 {503 listenTransformCommand(channel, name, id, message);504 }505 507 {508 linkMessageTransformCommand(sender, num, message, id);509 }510 }
Shape
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
1 // assembled by ../bin/lslcc -I. -I.. -I../.. shape.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 string parseWord; 9 10 11 12 qUserError(string message) 13 { 14 llOwnerSay(message); 15 } 16 17 18 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 38 { 39 if (level < __qDebugLevel) 40 __qError("DEBUG: " + message, file, line); 41 } 42 43 44 45 47 { 48 list command; 49 50 command = [ commandName ]; 51 52 return command; 53 } 54 55 56 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 104 {105 integer commandLength = llGetListLength(command);106 107 list parse = llParseString2List(text, [" "], []);108 integer parseLength = llGetListLength(parse);109 110 // make sure this is our command111 string parseCommand = llList2String(parse, 0);112 string commandCommand = llList2String(command, 0);113 114 string objectName = llGetObjectName();116 117 if ((parseCommand != "*") && // wildcard matches all commands118 (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 below127 {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 below136 {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 string171 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 switches192 193 195 {196 return qCommandAddSwitch(command, ["-debug", "integer"]);197 }198 200 {201 return qCommandAddSwitch(command, ["-reset"]);202 }203 205 {206 return qCommandAddSwitch(command, ["-die"]);207 }208 210 {211 if (llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)212 return qCommandAddSwitch(command, ["-help"]);213 214 else215 return command;216 }217 218 220 {221 command = qCommandAddDebugSwitch(command);222 command = qCommandAddResetSwitch(command);223 command = qCommandAddDieSwitch(command);224 command = qCommandAddHelpSwitch(command);225 226 return command;227 }228 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 {241 llResetScript();242 i++;243 }244 else if (switch == "-die")245 {246 llDie();247 i++;248 }249 250 else if (switch == "-help")251 {252 llGiveInventory(llGetOwner(), 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 274 {275 return global - llGetRegionCorner();276 }277 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 shapeCommand;315 316 buildShapeCommand()317 {318 shapeCommand = qCommandCreate("shape");319 shapeCommand = qCommandAddUniversalSwitches(shapeCommand);320 321 shapeCommand = qCommandAddSwitch(shapeCommand, ["-setType",322 "integer"]);323 shapeCommand = qCommandAddSwitch(shapeCommand, ["-setSculpt",324 "string", "integer"]);325 shapeCommand = qCommandAddSwitch(shapeCommand, ["-sleep",326 "integer"]);327 shapeCommand = qCommandAddSwitch(shapeCommand, ["-deleteScript"]);328 329 }330 331 332 333 initShapeCommand()334 {335 buildShapeCommand();336 338 339 integer privateChannel = llGetStartParameter();340 if (privateChannel != 0)342 }343 344 345 346 executeShapeCommand(list switches)347 {348 integer switchesLength = llGetListLength(switches);349 350 integer i;351 for (i = 1; i < switchesLength; i)352 {353 string switch = llList2String(switches, i);354 355 if (switch == "-setType")356 {357 integer type = llList2Integer(switches, i+1);358 359 if (type == 0)361 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);362 else if (type == 1)364 <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);365 366 else if (type == 2)368 <0.0, 0.0, 0.0>, <0.0, 0.0, 0.0>, <0.0, 0.0, 0.0>]);369 370 else if (type == 3)372 <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>]);373 374 else if (type == 4)376 <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>,377 <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);378 379 else if (type == 5)381 <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>,382 <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);383 384 else if (type == 6)386 <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>,387 <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);388 389 390 391 i+=2;392 }393 394 else if (switch == "-setCube")395 {396 // i follow the ordering in llSetPrimParams, which is different than397 // the user interface...398 integer holeType = llList2Integer(switches, i+1);399 float cutBegin = llList2Float(switches, i+2);400 float cutEnd = llList2Float(switches, i+3);401 float hollow = llList2Float(switches, i+4);402 float twistBegin = llList2Float(switches, i+5);403 float twistEnd = llList2Float(switches, i+6);404 float taperX = llList2Float(switches, i+7);405 float taperY = llList2Float(switches, i+8);406 float shearX = llList2Float(switches, i+9);407 float shearY = llList2Float(switches, i+10);408 410 <cutBegin, cutEnd, 0.0>, hollow,411 <twistBegin, twistEnd, 0.0>,412 <taperX, taperY, 0.0>,413 <shearX, shearY, 0.0>]);414 415 i += 11;416 }417 418 else if (switch == "-setSculpt")419 {420 string sculptTexture = llList2String(switches, i+1);421 integer sculptType = llList2Integer(switches, i+2);423 i+=3;424 }425 else if (switch == "-deleteScript")426 {427 llRemoveInventory(llGetScriptName());428 i++;429 }430 431 432 else if (switch == "-sleep")433 {434 llSleep(llList2Integer(switches, i+1));435 i+=2;436 }437 438 439 else440 i = qCommandExecuteUniversalSwitch(switches, i);441 442 }443 }444 445 446 447 parseShapeCommand(string message)448 {449 list switches = qCommandParseText(shapeCommand, message);450 451 if (switches != [])452 executeShapeCommand(switches);453 454 }455 456 458 {459 // we only accept commands on the public channel from our owner460 if ((channel == 500) &&461 (name != llKey2Name(llGetOwner())))462 return;463 464 parseShapeCommand(message);465 }466 467 469 {470 parseShapeCommand(message);471 }472 473 474 default475 {476 state_entry()477 {478 initShapeCommand();479 }480 482 {483 initShapeCommand();484 }485 487 {488 listenShapeCommand(channel, name, id, message);489 }490 492 {493 linkMessageShapeCommand(sender, num, message, id);494 }495 }
PrimScript
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
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 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 38 { 39 if (level < __qDebugLevel) 40 __qError("DEBUG: " + message, file, line); 41 } 42 43 44 45 46 48 { 49 list command; 50 51 command = [ commandName ]; 52 53 return command; 54 } 55 56 57 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 105 {106 integer commandLength = llGetListLength(command);107 108 list parse = llParseString2List(text, [" "], []);109 integer parseLength = llGetListLength(parse);110 111 // make sure this is our command112 string parseCommand = llList2String(parse, 0);113 string commandCommand = llList2String(command, 0);114 115 string objectName = llGetObjectName();117 118 if ((parseCommand != "*") && // wildcard matches all commands119 (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 below128 {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 below137 {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 string172 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 switches193 194 196 {197 return qCommandAddSwitch(command, ["-debug", "integer"]);198 }199 201 {202 return qCommandAddSwitch(command, ["-reset"]);203 }204 206 {207 return qCommandAddSwitch(command, ["-die"]);208 }209 211 {212 if (llGetInventoryType("Instruction Manual") == INVENTORY_NOTECARD)213 return qCommandAddSwitch(command, ["-help"]);214 215 else216 return command;217 }218 219 221 {222 command = qCommandAddDebugSwitch(command);223 command = qCommandAddResetSwitch(command);224 command = qCommandAddDieSwitch(command);225 command = qCommandAddHelpSwitch(command);226 227 return command;228 }229 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 {242 llResetScript();243 i++;244 }245 else if (switch == "-die")246 {247 llDie();248 i++;249 }250 251 else if (switch == "-help")252 {253 llGiveInventory(llGetOwner(), 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 polymorphism265 266 268 {269 if (a < b)270 return a;271 else272 return b;273 }274 276 {277 if (a > b)278 return a;279 else280 return b;281 }282 283 285 {286 if (value < min)287 return min;288 if (value > max)289 return max;290 291 return value;292 }293 294 295 298 float value)299 {300 float x = (value - origMin)/(origMax - origMin);301 302 return newMin + x * (newMax - newMin);303 }304 305 306 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 322 {324 325 return value - m * divisor;326 }327 329 {330 return llFrand(max - min) + min;331 }332 333 334 335 336 // computes bspline index - for either closed (periodic) or open bsplines.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 352 // vectors and creates a spline over353 // range [0..llGetListLength(vectors)] (uniform354 355 357 {358 float length = llGetListLength(vectors);359 361 float remains = value - floor;362 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.)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 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 432 {433 float o = llAngleBetween(a, b) / 2.0;434 436 return a;437 438 if (o > PI/2.0)439 a = (a - a); // take shortest path, please440 442 qRotationScale(llSin(t * o), b));443 444 c = qRotationScale(1.0 / llSin(o), c);445 446 return c;447 }448 449 451 {453 float remainder = value - base;454 456 457 if (remainder != 0)458 {460 valueStr += llGetSubString(remainderStr, 1, precision + 1);461 }462 463 return valueStr;464 }465 466 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 {505 506 vector place = (__qDynaOrigin +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 else560 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 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 else616 i = qCommandExecuteUniversalSwitch(switches, i);617 618 }619 }620 621 623 {624 // we only accept commands from our owner625 if (id != llGetOwner())626 return;627 628 list switches = qCommandParseText(command, message);629 630 if (switches != [])631 executeCommand(switches);632 }633 634 635 636 default637 {638 state_entry()639 {640 scriptRunning = 0;641 initCommand();642 }643 645 {646 if (data != EOF)647 {648 executeScriptLine(data);649 650 scriptLineNumber++;651 llGetNotecardLine(scriptKey, scriptLineNumber);652 }653 else654 endScript();655 }656 657 659 {660 if(!scriptRunning)661 listenCommand(channel, name, id, message);662 }663 664 }