├── ClothesListener.lsl ├── Controller.lsl ├── Extension.lsl ├── Greeter.lsl ├── LICENCE ├── Listener.lsl ├── NotecardMakerHUD.lsl ├── Peg.lsl ├── README.md ├── WaypointHUD.lsl ├── _0.scr ├── __config ├── __initcommands ├── __npc_names └── __permissions /ClothesListener.lsl: -------------------------------------------------------------------------------- 1 | /* Put this in an attachment that the NPC wears. You can then hide/show that attachment using the commands "hide" and "show" which are defined in the Extension.lsl script. 2 | 3 | Example: "Bob hide bottle" will show the attachment named (Object name) "bottle" 4 | "Bob show bottle" will hide it 5 | */ 6 | 7 | 8 | default 9 | { 10 | state_entry () 11 | { 12 | } 13 | 14 | 15 | // This receives messages through osMessageAttachments(). No channels are used 16 | dataserver(key qid, string mes) 17 | { 18 | string name = llGetObjectName(); 19 | if (mes == name+"-hide") { 20 | llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); 21 | } 22 | else if (mes == name+"-show") { 23 | llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES); 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Controller.lsl: -------------------------------------------------------------------------------- 1 | integer channel = 68; 2 | integer PEG_CHAN=699; 3 | integer TIMER_INTERVAL=5; // how often to run the timer 4 | integer autoLoadOnReset=0; 5 | string LASTNAME="(NPC)"; 6 | 7 | 8 | // Nothing to edit here, see https://github.com/opensimworld/active-npcs for configuration 9 | 10 | list availableNames = []; 11 | list lastNames = []; 12 | // These will be loaded from notecards 13 | list wNodes = []; 14 | list wLinks = []; 15 | list wNodeNames=[]; 16 | 17 | // list of nodes for the "Flyaround" command 18 | list flyTargets = []; 19 | 20 | list menuItems = ["SaveNPC", "LoadNPC", "RemoveNPC", "RemoveAll", "LoadAll", "ReConfig","InitCmds", "DumpData", "TimerOnOff", "Close"]; 21 | 22 | string userInputState =""; 23 | integer gListener; 24 | integer zListener; 25 | integer howmany; 26 | list avis; 27 | integer curVisitors=1; 28 | integer deflectToNode = -1; // if set, the NPCs will only run notecards at the specified waypoint 29 | 30 | list aviUids; 31 | list aviNames; 32 | list aviNodes; 33 | list aviPrevNodes; 34 | list aviStatus; 35 | list aviFollow; 36 | list aviCurrentAnim; 37 | list aviPath; 38 | list aviAlarm; 39 | list aviScriptIndex; 40 | list aviScriptText; 41 | list aviHttpId; 42 | list aviTarget; // user we are interacting with 43 | list scriptVars; 44 | list aviScriptState; 45 | list aviPrompts; 46 | list cache; 47 | 48 | 49 | integer aviIndex = -1; 50 | list seenArchive; 51 | 52 | list positionsList; 53 | list greetedAvis; 54 | integer timerRuns; 55 | integer timerRunning; 56 | integer curPoint; 57 | integer prevPoint; 58 | list wayPoints; 59 | list wayNames; 60 | list wayLinks; 61 | list wayKeys; 62 | string name; 63 | key npc; 64 | 65 | list candidateNode=[]; 66 | 67 | 68 | 69 | string vec2str(vector v) 70 | { 71 | return "<"+v.x+","+v.y+","+v.z+">"; 72 | } 73 | 74 | string GetLastName(string first) 75 | { 76 | integer idx = llListFindList(availableNames, [first]); 77 | if (idx >=0) return llList2String(lastNames, idx); 78 | else return LASTNAME; 79 | } 80 | 81 | key getAgentByName(string firstName) 82 | { 83 | firstName = llToLower(firstName); 84 | list ag = osGetAvatarList(); 85 | integer howmany = llGetListLength(ag); 86 | integer i; 87 | for (i =0; i < howmany; i+=3) 88 | { 89 | string name = llList2String(ag, i+2); 90 | integer sep = llSubStringIndex(name, " "); 91 | if (llToLower(llGetSubString(name, 0,sep-1)) == firstName) 92 | { 93 | return llList2Key(ag, i); 94 | } 95 | } 96 | return NULL_KEY; 97 | } 98 | 99 | string GetScriptVar(string cmd3) 100 | { 101 | integer i; 102 | for (i=0; i < llGetListLength(scriptVars); i+=2) 103 | { 104 | if (llList2String(scriptVars,i) == cmd3 ) 105 | { 106 | return llList2String(scriptVars, i+1); 107 | } 108 | } 109 | return ""; // default value; 110 | } 111 | 112 | 113 | integer ScriptJump(integer idx, string label, integer complain) 114 | { 115 | // Jump to a label in the notecard 116 | integer foundLine = FindScriptLineAfter(llList2String(aviScriptText,idx), "@"+label,-1); 117 | if (foundLine == -1) 118 | { 119 | if (complain) llOwnerSay("Error: @"+label+" label not found"); 120 | return 0; 121 | } 122 | else 123 | { 124 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [foundLine+1], idx, idx); 125 | return 1; 126 | } 127 | } 128 | 129 | list permList; 130 | string permCache; 131 | 132 | LoadPerms() 133 | { 134 | permList=[]; 135 | permCache = ""; 136 | if (llGetInventoryType("__permissions")==INVENTORY_NOTECARD) 137 | { 138 | llOwnerSay("Loading Permissions..."); 139 | list lines = llParseString2List(osGetNotecard("__permissions"), ["\n"], []); 140 | integer l; 141 | for (l=0;l=0) 273 | seenArchive = [] + llListReplaceList(seenArchive, [nm, llGetUnixTime()], fnd, fnd+1); 274 | else 275 | seenArchive = [] + seenArchive + [nm, llGetUnixTime()]; 276 | } 277 | } 278 | } 279 | return nNew; 280 | } 281 | 282 | doLoadNPC(string first, string last) 283 | { 284 | integer idx =(GetNPCIndex(first)); 285 | if (idx >=0) 286 | { 287 | llOwnerSay(first+ " is already in region, not loading"); 288 | osNpcStand(llList2Key(aviUids, idx)); 289 | return; 290 | } 291 | 292 | key unpc = osNpcCreate(first, last, llGetPos()+<0,0,3>, "APP_"+llToLower(first), OS_NPC_SENSE_AS_AGENT ); 293 | if (unpc != NULL_KEY) 294 | doAddNpc(first, unpc); 295 | } 296 | 297 | 298 | doAddNpc(string name, string unpc) 299 | { 300 | 301 | llOwnerSay( "Adding '"+name+"'"); 302 | aviUids += unpc; 303 | aviNames += llToLower(name); 304 | aviNodes += 1; 305 | aviPrevNodes += 0; 306 | aviStatus += ""; 307 | aviFollow += ""; 308 | aviCurrentAnim += ""; 309 | aviHttpId += ""; 310 | aviAlarm += -1; 311 | aviScriptIndex += -1; 312 | aviScriptText += ""; 313 | aviTarget += NULL_KEY; 314 | aviPath += ""; 315 | aviScriptState += ""; 316 | aviPrompts += ""; 317 | osNpcMoveToTarget(unpc, osNpcGetPos(unpc) + <1,0,0>, OS_NPC_NO_FLY ); 318 | } 319 | 320 | doRemoveNpc(string who) 321 | { 322 | integer idx = GetNPCIndex(who); 323 | if (idx <0) return; 324 | 325 | key u = llList2Key(aviUids, idx); 326 | aviNames = [] + llDeleteSubList(aviNames, idx, idx); 327 | aviUids = [] + llDeleteSubList(aviUids, idx, idx); 328 | aviNodes = [] + llDeleteSubList(aviNodes, idx, idx); 329 | aviPrevNodes = [] + llDeleteSubList(aviNodes, idx, idx); 330 | aviFollow = [] + llDeleteSubList(aviFollow, idx, idx); []; 331 | aviStatus = [] + llDeleteSubList(aviStatus, idx, idx); 332 | aviCurrentAnim = [] + llDeleteSubList(aviCurrentAnim, idx, idx); 333 | aviPath = [] + llDeleteSubList(aviPath, idx, idx); 334 | aviHttpId = [] + llDeleteSubList(aviHttpId, idx, idx); 335 | aviAlarm = [] + llDeleteSubList(aviAlarm, idx, idx); 336 | aviScriptIndex = [] + llDeleteSubList(aviScriptIndex, idx, idx); 337 | aviScriptText = [] + llDeleteSubList(aviScriptText, idx, idx); 338 | aviTarget = [] + llDeleteSubList(aviTarget, idx, idx); 339 | aviScriptState = [] + llDeleteSubList(aviScriptState, idx, idx); 340 | aviPrompts = [] + llDeleteSubList(aviPrompts, idx, idx); 341 | 342 | llOwnerSay("Removing "+who + ""); 343 | osNpcStand(u); 344 | osNpcRemove(u); 345 | } 346 | 347 | doLoadAll() 348 | { 349 | integer i; 350 | for (i=0; i < llGetListLength(availableNames);i++) 351 | { 352 | doLoadNPC(llList2String(availableNames, i), llList2String(lastNames, i)); 353 | } 354 | 355 | } 356 | 357 | 358 | doInitCmds() 359 | { 360 | string notecard= "__initcommands"; 361 | integer i; 362 | for(i=0; i<=osGetNumberOfNotecardLines(notecard); i++) { 363 | string line = llStringTrim(osGetNotecardLine(notecard, i), STRING_TRIM); 364 | if (llStringLength(line)>0 && line != "") 365 | { 366 | list l = llParseString2List(line, [" "], []); 367 | line = "! "+(string)NULL_KEY+" "+llList2String(l,0)+" "+ line; 368 | llOwnerSay("InitCmd="+line); 369 | ProcessNPCCommand(line); 370 | } 371 | } 372 | 373 | } 374 | 375 | setVar(string cmd2, string cmd3) 376 | { 377 | integer i; 378 | for (i=0; i < llGetListLength(scriptVars); i+=2) 379 | { 380 | if (llList2String(scriptVars,i) == cmd2) 381 | { 382 | scriptVars = [] + llListReplaceList(scriptVars, [cmd3], i+1, i+1); 383 | return; 384 | } 385 | } 386 | scriptVars += cmd2; 387 | scriptVars += cmd3; 388 | } 389 | 390 | 391 | integer RescanAvis() 392 | { 393 | avis = osGetAvatarList(); 394 | howmany = llGetListLength(avis); 395 | integer i; 396 | for (i =0; i < howmany; i+=3) 397 | { 398 | if (osIsNpc(llList2Key(avis, i))) 399 | { 400 | integer sep = llSubStringIndex(llList2Key(avis, i+2), " "); 401 | string nm = llGetSubString(llList2Key(avis, i+2), 0, sep-1 ); 402 | doAddNpc(nm, llList2Key(avis, i)); 403 | } 404 | } 405 | llOwnerSay(llList2CSV(aviNames)); 406 | llOwnerSay(llList2CSV(aviStatus)); 407 | return llGetListLength(aviUids); 408 | } 409 | 410 | 411 | LoadMapData() 412 | { 413 | integer tl = osGetNumberOfNotecardLines("__waypoints"); 414 | integer i; 415 | wNodes = []; 416 | for (i=0; i < tl; i++) 417 | { 418 | string line = osGetNotecardLine("__waypoints",i); 419 | list tok = llParseStringKeepNulls(line, [","], []); 420 | float x = llList2Float(tok,0); 421 | if (x>0) 422 | { 423 | vector v = ; 424 | wNodes += v; 425 | wNodeNames += llList2String(tok,3); 426 | } 427 | } 428 | llOwnerSay("loaded "+(string)(llGetListLength(wNodes))+" waypoints"); 429 | 430 | 431 | integer tnodes = llGetListLength(wNodes); 432 | wLinks = []; 433 | tl = osGetNumberOfNotecardLines("__links"); 434 | for (i=0; i < tl; i++) 435 | { 436 | string line = osGetNotecardLine("__links",i); 437 | list tok = llParseString2List(line, [","],""); 438 | integer a= llList2Integer(tok,0); 439 | integer b = llList2Integer(tok,1); 440 | if (a !=b) 441 | wLinks += [a,b]; 442 | } 443 | llOwnerSay("loaded "+(string)(llGetListLength(wLinks)/2)+" links"); 444 | cache = []; 445 | } 446 | 447 | 448 | integer GetNPCIndex(string name) /// name is in lowercase 449 | { 450 | return llListFindList(aviNames, [llToLower(name)]); 451 | } 452 | 453 | 454 | integer GetWalkTime(float distance) 455 | { 456 | return llCeil(distance / 1.7); 457 | } 458 | 459 | integer GetNearestNode(vector pos) 460 | { 461 | integer i; 462 | float min = 9999991.; 463 | integer l =-1; 464 | for (i=0;i < llGetListLength(wNodes); i++) 465 | { 466 | float dist = llVecDist(pos, llList2Vector(wNodes,i)); 467 | if (dist < min) 468 | { 469 | min = dist; 470 | l=i; 471 | } 472 | } 473 | return l; 474 | } 475 | 476 | list foundPaths; 477 | // Get path through LSL -- Slow 478 | integer GenPaths(integer a, integer tgt, string path, integer depth) 479 | { 480 | if (depth > 17) 481 | { 482 | //llOwnerSay("Bailing at " + path); 483 | return 0; 484 | } 485 | integer i; 486 | for (i=0; i < llGetListLength(wLinks); i+=2) 487 | { 488 | integer ca = llList2Integer(wLinks, i); 489 | integer cb = llList2Integer(wLinks, i+1); 490 | integer fn = -1; 491 | if (cb == a || ca == a) 492 | { 493 | if (cb == a) 494 | fn = ca; 495 | else if (ca == a) 496 | fn = cb; 497 | if (llSubStringIndex(path, ":"+fn+":")<0) 498 | { 499 | if (fn == tgt) 500 | { 501 | path += ""+fn+":"; 502 | foundPaths += (path); 503 | return 1; 504 | } 505 | else 506 | { 507 | 508 | GenPaths(fn, tgt, path+fn+":", depth+1); 509 | } 510 | } 511 | } 512 | 513 | if (llGetListLength(foundPaths)>30) 514 | return 2; 515 | } 516 | return 0; 517 | } 518 | 519 | 520 | 521 | 522 | 523 | string GetGotoPath(integer nodeA, integer nodeB) 524 | { 525 | integer i; 526 | integer ww; 527 | 528 | 529 | string tmpPath = ":"+(string)nodeA+":"; 530 | 531 | foundPaths = []; 532 | GenPaths(nodeA, nodeB, tmpPath, 0); 533 | //llOwnerSay(llList2CSV(foundPaths)); 534 | if (llGetListLength(foundPaths) ==0) 535 | return ""; 536 | integer min = 99999; 537 | string least = ""; 538 | for (i=0; i < llGetListLength(foundPaths); i++) 539 | { 540 | ww = llStringLength(llList2String(foundPaths, i)); 541 | if (ww < min) 542 | { 543 | min = ww; 544 | least = llList2String(foundPaths, i); 545 | } 546 | } 547 | //llOwnerSay(least); 548 | return least; 549 | } 550 | 551 | 552 | 553 | integer GetNPCIndexByUid(key name) 554 | { 555 | return llListFindList(aviUids, [name]); 556 | } 557 | 558 | 559 | string GetScriptLine(string scriptData, integer line) 560 | { 561 | list scriptLines = llParseStringKeepNulls(scriptData, ["\n",";"], []); 562 | return llList2String(scriptLines, line-1); 563 | } 564 | 565 | integer FindScriptLineAfter(string scriptData, string lineToFind, integer afterLine) 566 | { 567 | integer endIdx; 568 | list scriptLines = llParseStringKeepNulls(scriptData, ["\n",";"], []); 569 | string toFind = llToLower(lineToFind); 570 | integer foundLine = -1; 571 | string line; 572 | for (endIdx = afterLine+1;endIdx < llGetListLength(scriptLines); endIdx++) 573 | { 574 | line = llList2String(scriptLines, endIdx); 575 | if (llStringTrim(line, STRING_TRIM) == toFind) 576 | { 577 | foundLine =endIdx; 578 | jump _foundIdxOut; 579 | } 580 | } 581 | @_foundIdxOut; 582 | return foundLine; 583 | } 584 | 585 | 586 | integer FindMatchingEndif(string scriptData, integer afterLine) 587 | { 588 | integer endIdx; 589 | list scriptLines = llParseStringKeepNulls(scriptData, ["\n",";"], []); 590 | string toFind = "end-if"; 591 | integer foundLine = -1; 592 | string line; 593 | integer ifLevel=1; 594 | for (endIdx = afterLine+1;endIdx < llGetListLength(scriptLines); endIdx++) 595 | { 596 | line = llStringTrim(llList2String(scriptLines, endIdx), STRING_TRIM); 597 | if (llGetSubString(line, 0, 1) == "if") 598 | { 599 | ifLevel++; 600 | } 601 | else if (line == "end-if") 602 | { 603 | ifLevel--; 604 | if (ifLevel==0) 605 | { 606 | foundLine =endIdx; 607 | jump _foundEIIdxOut; 608 | } 609 | } 610 | } 611 | @_foundEIIdxOut; 612 | return foundLine; 613 | } 614 | 615 | integer GetNodeIndexByName(string nodeName) 616 | { 617 | integer i; 618 | nodeName = llToLower(nodeName); 619 | for (i=0; i < llGetListLength(wNodeNames); i++) 620 | { 621 | if (llToLower(llList2String(wNodeNames, i)) == nodeName) 622 | { 623 | return i; 624 | } 625 | } 626 | return -1; 627 | } 628 | 629 | SetScriptAlarm(integer aviId, integer time) 630 | { 631 | aviAlarm = [] + llListReplaceList(aviAlarm, [llGetUnixTime() + time], aviId, aviId); 632 | } 633 | 634 | 635 | doStopNpc(integer idx, key uNPC) 636 | { 637 | aviStatus = [] + llListReplaceList(aviStatus, [""], idx, idx); 638 | SetScriptAlarm(idx, 0); 639 | list anToStop=llGetAnimationList(uNPC); 640 | integer stop=llGetListLength(anToStop); 641 | while (--stop>=0) { osNpcStopAnimation(uNPC,llList2Key(anToStop,stop)); } 642 | osNpcStopMoveToTarget(uNPC); 643 | osNpcStand(uNPC); 644 | } 645 | 646 | // Handler for all commands coming from chat 647 | integer ProcessNPCCommand(string inputString) 648 | { 649 | 650 | list tokens = llParseString2List(inputString, [" "], []); 651 | // first token should be just "!" 652 | 653 | //llOwnerSay("<<" + inputString); 654 | key sendUid = llList2Key(tokens,1); 655 | string npcName = llToLower(llList2String(tokens,2)); 656 | string name2 = llToLower(llList2String(tokens,3)); 657 | //if (npcName != name2) npcName = name2; 658 | 659 | integer idx = GetNPCIndex(npcName); 660 | if (idx <0) 661 | { 662 | return 1; 663 | } 664 | 665 | key uNPC= llList2Key(aviUids, idx); 666 | if (uNPC == NULL_KEY) 667 | { 668 | return 1; 669 | } 670 | 671 | 672 | 673 | if (llSubStringIndex(inputString, "$")>=0) //substiute variables 674 | { 675 | integer i; 676 | for (i=4; i < llGetListLength(tokens); i++) 677 | { 678 | string st = llList2String(tokens,i); 679 | if (llSubStringIndex(st, "$")==0) 680 | { 681 | tokens = [] + llListReplaceList(tokens, [ GetScriptVar(llGetSubString(st,1,-1) ) ], i , i); 682 | } 683 | } 684 | } 685 | 686 | string cmd1= llList2String(tokens,4); 687 | string cmd2= llList2String(tokens,5); 688 | list userData; 689 | 690 | if (sendUid!= NULL_KEY && (llGetAgentSize(sendUid) != ZERO_VECTOR)) 691 | { 692 | if (!IsAllowed(npcName, cmd1, sendUid)) 693 | { 694 | llOwnerSay("Denied '"+cmd1+"' to "+(string)sendUid+" "+llKey2Name(sendUid)); 695 | return 1; 696 | } 697 | } 698 | 699 | 700 | if (llList2String(aviStatus, idx) == "prompt") 701 | { 702 | aviStatus = []+llListReplaceList(aviStatus, [""], idx, idx); // Turn off prompt in sync with the listener 703 | if (npcName != name2 ) // it (probably) a response to the prompt, rather than a command given to the npc 704 | { 705 | integer i; 706 | for (i=3; i < llGetListLength(tokens); i++) 707 | { 708 | 709 | if ( llSubStringIndex(llList2String(aviPrompts, idx), "["+llToLower(llList2String(tokens, i))+"]" ) > 0) // label existed in prompt 710 | { 711 | aviTarget = []+llListReplaceList(aviTarget, [sendUid], idx, idx); 712 | ScriptJump(idx, llToLower(llList2String(tokens, i)) , 1); 713 | return 1; 714 | } 715 | } 716 | return 1; 717 | } 718 | } 719 | 720 | 721 | if (cmd1 == "stop") 722 | { 723 | doStopNpc(idx, uNPC); 724 | } 725 | else if (cmd1 == "come") 726 | { 727 | doStopNpc(idx, uNPC); 728 | userData=llGetObjectDetails((key)sendUid, [OBJECT_NAME,OBJECT_POS, OBJECT_ROT]); 729 | osNpcStopMoveToTarget(uNPC); 730 | osTeleportAgent(uNPC, llList2Vector(userData, 1) + <1, 0, 0>, <1,1,1>); 731 | if (sendUid != NULL_KEY) // NOTE: a real avatar sent this command - stop processing our script 732 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, -1, idx, idx); 733 | } 734 | else if (cmd1 == "stand") 735 | { 736 | aviStatus = []+llListReplaceList(aviStatus, [""], idx, idx); 737 | osNpcStand(uNPC); 738 | osNpcStopMoveToTarget(uNPC); 739 | } 740 | else if (cmd1 == "moveto" || cmd1 == "movetov" || cmd1 == "runtovr"|| cmd1 == "movetovr" || cmd1 == "flytov" || cmd1 == "runtov" || cmd1=="walk" ) 741 | { 742 | // Walk to the specified waypoint or vector 743 | vector v; 744 | string anim =""; // Specify an animation to play while walking 745 | if (cmd1 == "runtovr"||cmd1 == "movetovr") 746 | { 747 | // run to somewhere within the volume enclosed by v1 and v2 748 | vector v1 = (vector) cmd2; 749 | vector v2 = (vector) llList2String(tokens, 6); 750 | v.x= v1.x + llFrand(v2.x-v1.x); 751 | v.y= v1.y + llFrand(v2.y-v1.y); 752 | v.z= v1.z + llFrand(v2.z-v1.z); 753 | anim = llList2String(tokens, 7); 754 | } 755 | else if (cmd1 == "movetov" || cmd1 == "flytov" ||cmd1 == "runtov" || cmd1 =="walk") 756 | { 757 | v = (vector)cmd2; 758 | if (v == ZERO_VECTOR) 759 | { 760 | llOwnerSay(npcName + ": "+cmd2+" is not a good position. I am not going there!"); 761 | return 1; 762 | } 763 | anim = llList2String(tokens, 6); 764 | } 765 | else 766 | v = llList2Vector(wNodes, (integer)cmd2); 767 | 768 | float dist = llVecDist(osNpcGetPos(uNPC), v); 769 | 770 | if (cmd1 == "runtovr"|| cmd1 == "runtov") 771 | { 772 | osSetSpeed(uNPC, 1.0); 773 | osNpcMoveToTarget(uNPC, v + <0,0,1>, OS_NPC_NO_FLY | OS_NPC_RUNNING); 774 | SetScriptAlarm(idx, (integer)(GetWalkTime(dist)/2.)); 775 | } 776 | else 777 | { 778 | if (anim == "") 779 | osNpcStand(uNPC); 780 | osNpcStopMoveToTarget(uNPC); 781 | osSetSpeed(uNPC, 0.5); 782 | if (cmd1 == "flytov") 783 | osNpcMoveToTarget(uNPC, v + <0,0,1>, OS_NPC_FLY ); 784 | else 785 | osNpcMoveToTarget(uNPC, v + <0,0,1>, OS_NPC_NO_FLY); 786 | if (anim) 787 | { 788 | llSleep(0.5); 789 | osNpcPlayAnimation(uNPC, anim); 790 | } 791 | 792 | SetScriptAlarm(idx, GetWalkTime(dist)); 793 | } 794 | } 795 | else if (cmd1 == "setvar") 796 | { 797 | string cmd3 = llList2String(tokens,6); 798 | setVar(cmd2, cmd3); 799 | return 0; 800 | } 801 | else if (cmd1 == "if" || cmd1 == "if-not" || cmd1=="if-prob") 802 | { 803 | integer res = 0; 804 | if (cmd1 == "if-prob") 805 | { 806 | if (llFrand(1.0)<(float)cmd2) 807 | res = 1; 808 | } 809 | else if (cmd2 == "name-is") 810 | { 811 | integer k; 812 | res=0; 813 | for (k=6; k < llGetListLength(tokens); k++) 814 | { 815 | if (llToLower(npcName) == llToLower(llList2String(tokens,k))) 816 | { 817 | setVar("_found", npcName); 818 | res=1; 819 | } 820 | } 821 | } 822 | else if (cmd2 == "var-is") 823 | { 824 | integer k; 825 | res=0; 826 | for (k=6; k < llGetListLength(tokens); k+=2) 827 | { 828 | string nm = llList2String(tokens,k); 829 | if (nm == "") jump varIsBreak; 830 | string val = llList2String(tokens,k+1); 831 | if (GetScriptVar(nm) == val) 832 | res =1; 833 | else 834 | { 835 | res=0; 836 | jump varIsBreak; 837 | } 838 | } 839 | @varIsBreak; 840 | } 841 | else if (cmd2 == "state-is") 842 | { 843 | // If state-is 844 | integer nwho = GetNPCIndex(llList2String(tokens,6)); 845 | if (nwho >=0) 846 | { 847 | string what = llList2String(aviScriptState,nwho); 848 | integer k; 849 | for (k=7; k < llGetListLength(tokens); k++) 850 | { 851 | if (what == llList2String(tokens,k)) 852 | res=1; 853 | } 854 | } 855 | } 856 | 857 | if (cmd1 == "if-not") 858 | res = !res; 859 | 860 | integer scrline = llList2Integer(aviScriptIndex, idx); 861 | if (scrline <0) 862 | { 863 | return 1; // wtf 864 | } 865 | 866 | if (!res) 867 | { 868 | integer foundLine = FindMatchingEndif(llList2String(aviScriptText,idx), scrline-1); /// this used to skip a line 869 | if (foundLine == -1) 870 | { 871 | llOwnerSay("Error: end-if not found afterr "+cmd1 + " "+cmd2 + "..."); 872 | } 873 | else 874 | { 875 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [foundLine+1], idx, idx);// Go past the end-if -- runs notecards faster 876 | } 877 | } 878 | return 0; 879 | } 880 | else if (cmd1 == "end-if") 881 | { 882 | // Do nothing 883 | return 0; 884 | } 885 | else if (cmd1 == "prompt") 886 | { 887 | string prompt = llDumpList2String(llList2List(tokens, 5, -1), " "); 888 | aviStatus = []+llListReplaceList(aviStatus, ["prompt"], idx, idx); 889 | osNpcSay(uNPC, prompt); 890 | aviPrompts = []+llListReplaceList(aviPrompts, [llToLower(inputString)], idx, idx); 891 | aviTarget = []+llListReplaceList(aviTarget, [NULL_KEY], idx, idx); 892 | osMessageAttachments(uNPC, "prompt", [ATTACH_RIGHT_PEC], 0); 893 | } 894 | else if (cmd1 == "jump") 895 | { 896 | // Jump to a label in the notecard 897 | ScriptJump(idx, llToLower(cmd2), 1); 898 | return 0; // process next cmd immediately 899 | } 900 | else if ((cmd1 == "go" && cmd2 == "to") || cmd1 == "goto") 901 | { 902 | // Pathfinding command 903 | integer nearest = GetNearestNode(osNpcGetPos(uNPC)); 904 | integer foundId =-1; 905 | if (cmd1 == "goto") 906 | { 907 | foundId = (integer) cmd2; 908 | } 909 | else 910 | { 911 | string where = llToLower(llStringTrim(llList2String(tokens,6) +" "+ llList2String(tokens,7) +" "+ llList2String(tokens,8), STRING_TRIM)); 912 | integer i; 913 | if (where != "") 914 | foundId = GetNodeIndexByName(where); 915 | 916 | if (foundId <0) 917 | { 918 | list tmp; 919 | for (i=0; i < llGetListLength(wNodeNames); i++) 920 | if (llList2String(wNodeNames,i) != "") 921 | tmp += llList2String(wNodeNames, i); 922 | osNpcSay(uNPC, "Sorry i dont know how to get to the "+where+ ". Here's some of the places i know: " +llList2CSV(tmp)); 923 | return 1; 924 | } 925 | } 926 | 927 | osNpcSay(uNPC, "Let me think... "); 928 | string cachekey = "f,"+(string)nearest+","+(string)foundId; 929 | string gotoPath =""; 930 | integer fidx = llListFindList(cache, [cachekey]); 931 | if (fidx>=0) 932 | { 933 | gotoPath = llList2String(cache, fidx+1); 934 | } 935 | else 936 | { 937 | gotoPath = GetGotoPath(nearest, foundId); 938 | if (gotoPath != "") 939 | { 940 | cache += cachekey; 941 | cache += gotoPath; 942 | } 943 | } 944 | if (gotoPath == "") 945 | { 946 | osNpcSay(uNPC, "I 'm dumb. i don't know how to get there ... "); 947 | return 1; 948 | } 949 | osNpcSay(uNPC, "If you want to go there, follow me."); 950 | SetScriptAlarm(idx, 0); 951 | aviPath = []+ llListReplaceList(aviPath, [gotoPath], idx, idx); 952 | aviStatus = []+llListReplaceList(aviStatus, ["pathf"], idx, idx); 953 | } 954 | else if (cmd1 == "setpath") 955 | { 956 | //Path must be in format 2:4:63:22:1 where the numbers are the waypoints numbers 957 | aviPath = []+ llListReplaceList(aviPath, [cmd2], idx, idx); 958 | SetScriptAlarm(idx, 0); 959 | aviStatus = []+llListReplaceList(aviStatus, ["pathf"], idx, idx); 960 | } 961 | else if (cmd1 == "waitvar") 962 | { 963 | // Wait until the value of variable named cmd2 reaches the value cmd3 964 | string cmd3 = llList2String(tokens,6); 965 | string vval = GetScriptVar(cmd2); 966 | 967 | if (vval == cmd3) 968 | { 969 | return 1; /// OK continue with the next line 970 | } 971 | else if (cmd3 == "NONEMPTY" && vval != "") 972 | { 973 | return 1; 974 | } 975 | 976 | integer scriptIndex = llList2Integer(aviScriptIndex, idx); 977 | if (scriptIndex>0) 978 | { 979 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [scriptIndex-1], idx, idx); 980 | } 981 | } 982 | else if (cmd1 == "increase" || cmd1 == "decrease" || cmd1 == "zero") 983 | { 984 | integer v = (integer)GetScriptVar(cmd2); 985 | if (cmd1=="increase") v++; 986 | else if (cmd1 == "decrease") v--; 987 | else v=0; 988 | setVar(cmd2, (string)v); 989 | return 1; 990 | } 991 | else if (cmd1 == "wait") 992 | { 993 | integer tm = (integer)cmd2; 994 | integer tm2 = (integer)llList2String(tokens,6); 995 | if (tm2>0) 996 | tm = (integer)(tm + llFrand(tm2)); 997 | SetScriptAlarm(idx, tm); 998 | } 999 | else if (cmd1 == "say" || cmd1 == "shout") 1000 | { 1001 | // Say something on chat 1002 | string txt = ""; 1003 | integer i; 1004 | for (i=5; i < llGetListLength(tokens); i++) 1005 | txt += llList2String(tokens,i) + " "; 1006 | if (cmd1 == "shout") 1007 | osNpcShout(uNPC, 0, txt); 1008 | else 1009 | osNpcSay(uNPC, txt); 1010 | return 0; 1011 | } 1012 | else if (cmd1 == "saych") 1013 | { 1014 | // Say something on channel 1015 | string txt = ""; 1016 | integer i; 1017 | for (i=6; i < llGetListLength(tokens); i++) 1018 | txt += llList2String(tokens,i) + " "; 1019 | osNpcSay(uNPC, llList2Integer(tokens,5), txt); 1020 | } 1021 | else if (cmd1 == "loadnpc") 1022 | { 1023 | doLoadNPC(cmd2, llList2String(tokens, 6)); 1024 | } 1025 | else if (cmd1 == "removenpc") 1026 | { 1027 | doRemoveNpc(cmd2); 1028 | } 1029 | else if (cmd1 == "exec") 1030 | { 1031 | list tok2 = ["!", (string)NULL_KEY, cmd2] + llList2List(tokens, 5, -1); 1032 | //llOwnerSay(llList2CSV(tok2)); 1033 | ProcessNPCCommand(llDumpList2String(tok2, " ")); 1034 | } 1035 | 1036 | else if (cmd1 == "msgatt") 1037 | { 1038 | 1039 | list points = []; 1040 | integer i; 1041 | for (i=6; i < llGetListLength(tokens); i++) 1042 | { 1043 | if (llList2Integer(tokens, i)>0) 1044 | points += llList2Integer(tokens,i); 1045 | } 1046 | osMessageAttachments(uNPC, cmd2, points, 0); 1047 | } 1048 | else if (cmd1 == "teleport") 1049 | { 1050 | vector w = (vector) cmd2; 1051 | if (w == ZERO_VECTOR) 1052 | { 1053 | integer where = GetNodeIndexByName(cmd2); 1054 | if (where >=0) 1055 | { 1056 | w = llList2Vector(wNodes, where); 1057 | osTeleportAgent(uNPC, w, <0,0,0>); 1058 | } 1059 | } 1060 | else osTeleportAgent(uNPC, w, <0,0,0>); 1061 | } 1062 | else if (cmd1 == "use") 1063 | { 1064 | // Sit-on-a-poseball command 1065 | string cmd = llStringTrim(cmd2+" "+llList2String(tokens, 6)+" "+llList2String(tokens,7), STRING_TRIM); 1066 | osMessageAttachments(uNPC, "do "+cmd, [ATTACH_RIGHT_PEC], 0); 1067 | } 1068 | else if (cmd1 == "lookat") 1069 | { 1070 | vector v; 1071 | if (cmd2=="me") 1072 | { 1073 | userData=llGetObjectDetails((key)sendUid, [OBJECT_NAME,OBJECT_POS, OBJECT_ROT]); 1074 | v = llList2Vector(userData,1); 1075 | } 1076 | else 1077 | { 1078 | v = (vector)cmd2; 1079 | if (v == ZERO_VECTOR) 1080 | { 1081 | integer midx = GetNodeIndexByName(llToLower(cmd2)); 1082 | if (midx >=0) 1083 | { 1084 | v = llList2Vector(wNodes, midx); 1085 | } 1086 | } 1087 | } 1088 | osNpcSetRot(uNPC, llRotBetween(<1,0,0>, v-osNpcGetPos(uNPC)));//llEuler2Rot(<0,0,ang>)); 1089 | } 1090 | else if (cmd1 == "anim") 1091 | { 1092 | osNpcStopAnimation(uNPC, llList2String(aviCurrentAnim, idx)); 1093 | aviCurrentAnim = llListReplaceList(aviCurrentAnim, [cmd2], idx, idx); 1094 | osNpcPlayAnimation(uNPC, cmd2); 1095 | } 1096 | else if (cmd1 == "give") 1097 | { 1098 | if (llGetInventoryType(cmd2) == INVENTORY_OBJECT) 1099 | llGiveInventory(sendUid, cmd2); 1100 | } 1101 | else if (cmd1 == "light") 1102 | osMessageAttachments(uNPC, "light", [ATTACH_RIGHT_PEC], 0); 1103 | else if (cmd1 == "sound") 1104 | osMessageAttachments(uNPC, "sound " + cmd2+" "+llList2String(tokens, 6) , [ATTACH_RIGHT_PEC], 0); 1105 | else if (cmd1 == "batch") 1106 | { 1107 | // Run multiple commands from the chat, separated by ";" --- replaces any running script 1108 | string str = llDumpList2String(llList2List(tokens, 5, llGetListLength(tokens))," "); 1109 | aviScriptText = []+llListReplaceList(aviScriptText, str, idx, idx); 1110 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [1], idx, idx); 1111 | aviStatus = []+llListReplaceList(aviStatus, "", idx, idx); 1112 | SetScriptAlarm(idx, 0); 1113 | } 1114 | else if (cmd1 == "follow") 1115 | { 1116 | aviStatus = []+llListReplaceList(aviStatus, ["follow"], idx, idx); 1117 | if (cmd2=="me" || cmd2=="") 1118 | { 1119 | userData=llGetObjectDetails((key)sendUid, [OBJECT_NAME,OBJECT_POS, OBJECT_ROT]); 1120 | aviFollow = []+llListReplaceList(aviFollow, [(key)sendUid], idx, idx); 1121 | osNpcSay(uNPC, "Following you "+ llList2String(userData, 0)); 1122 | } 1123 | else 1124 | { 1125 | key who = getAgentByName(cmd2); 1126 | if (who != NULL_KEY) 1127 | { 1128 | aviFollow = []+llListReplaceList(aviFollow, [who], idx, idx); 1129 | osNpcSay(uNPC, "Following " + cmd2); 1130 | } 1131 | } 1132 | 1133 | } 1134 | else if (cmd1 == "set-state") // set a variable that indicates the current state of an NPC -- useful for scripts 1135 | { 1136 | aviScriptState= []+llListReplaceList(aviScriptState, [cmd2], idx, idx); 1137 | return 0; 1138 | } 1139 | else if (cmd1 == "debug") 1140 | { 1141 | integer dd = llList2Integer(aviScriptIndex, idx); 1142 | string scr; 1143 | if (dd >=0) 1144 | { 1145 | scr = GetScriptLine(llList2String(aviScriptText,idx) , dd-1); 1146 | } 1147 | llOwnerSay("Status="+llList2String(aviStatus, idx)+" node = "+llList2Integer(aviNodes, idx)+ 1148 | " follow="+llList2String(aviFollow, idx)+" Alarm = "+(string)(llList2Integer(aviAlarm,idx)-llGetUnixTime())+ 1149 | " scriptIndex="+llList2Integer(aviScriptIndex, idx)+" scriptText " +scr ); 1150 | } 1151 | else if (cmd1 == "fly" && cmd2=="with") // "fly with me" "fly with Foo" 1152 | { 1153 | string who = llList2String(tokens, 6); 1154 | if (who == "me") 1155 | { 1156 | aviFollow = []+llListReplaceList(aviFollow, [(key)sendUid], idx, idx); 1157 | } 1158 | else 1159 | { 1160 | key w = getAgentByName(who); 1161 | if (w != NULL_KEY) 1162 | { 1163 | aviFollow = []+llListReplaceList(aviFollow, [w], idx, idx); 1164 | 1165 | } 1166 | } 1167 | aviStatus = llListReplaceList(aviStatus, ["flyfollow"], idx, idx); 1168 | osNpcSay(uNPC, "Flying "); 1169 | } 1170 | else if (cmd1 == "leave") 1171 | { 1172 | // Start wandering between waypoints 1173 | osNpcStand(uNPC); 1174 | aviNodes = []+llListReplaceList(aviNodes, [GetNearestNode(osNpcGetPos(uNPC))], idx, idx); 1175 | aviStatus = []+llListReplaceList(aviStatus, ["wander"], idx, idx); 1176 | aviPrevNodes = []+llListReplaceList(aviPrevNodes, [-1], idx, idx); 1177 | } 1178 | else if (cmd1 == "flyaround") 1179 | { 1180 | // Start flying about between the waypoints in the "flyTargets" list -- useful for birds 1181 | aviStatus = []+llListReplaceList(aviStatus, ["godfly"], idx, idx); 1182 | osNpcSay(uNPC, "Flying like an eagle!!"); 1183 | 1184 | } 1185 | else if (cmd1 == "run-notecard") 1186 | { 1187 | // Run the script contained in the notecard 1188 | string stext= osGetNotecard(cmd2 ); 1189 | aviStatus= []+llListReplaceList(aviStatus, "", idx, idx); 1190 | if (stext == "ERROR") 1191 | { 1192 | llOwnerSay("Notecard error "+cmd2); 1193 | return 1; 1194 | } 1195 | aviScriptText = []+llListReplaceList(aviScriptText, stext, idx, idx); 1196 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [1], idx, idx); 1197 | SetScriptAlarm(idx, 0); 1198 | } 1199 | else if (cmd1 == "stop-script") 1200 | { 1201 | // Stop executing the script and exit 1202 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [-1], idx, idx); 1203 | SetScriptAlarm(idx, 0); 1204 | } 1205 | else if (cmd1 == "dress") 1206 | { 1207 | string suff = ""; 1208 | if (cmd2 != "") suff += "_"+cmd2; 1209 | string nm = llList2String(aviNames, idx); 1210 | llOwnerSay("Loading appearance "+"APP_"+nm+suff); 1211 | osNpcLoadAppearance(uNPC, "APP_"+nm+suff); 1212 | } 1213 | else if (cmd1 == "touch") 1214 | { 1215 | osNpcTouch(uNPC, (key)cmd2, LINK_ROOT); 1216 | } 1217 | else if (cmd1 == "seen") 1218 | { 1219 | integer i; 1220 | if (cmd2 == "all") 1221 | { 1222 | for (i=0; i < llGetListLength(seenArchive); i+=2) 1223 | osNpcSay(uNPC, "I saw "+ llList2String(seenArchive,i) + " " + TimeAgo(llList2Integer(seenArchive,i+1) )); 1224 | return 1; 1225 | } 1226 | else 1227 | { 1228 | for (i=0; i < llGetListLength(seenArchive); i+=2) 1229 | { 1230 | if (llSubStringIndex(llToLower(llList2String(seenArchive,i)), llToLower(cmd2))>=0) 1231 | { 1232 | osNpcSay(uNPC, "I saw "+ llList2String(seenArchive,i) + " around " + TimeAgo(llList2Integer(seenArchive,i+1) )); 1233 | return 1; 1234 | } 1235 | } 1236 | } 1237 | osNpcSay(uNPC, "I haven't seen "+ cmd2 + " around"); 1238 | } 1239 | else if (cmd1 == "nearest") 1240 | { 1241 | integer n = GetNearestNode(osNpcGetPos(uNPC)); 1242 | osNpcSay(uNPC, "Nearest waypoint is #"+n); 1243 | } 1244 | else if (llGetSubString(cmd1,0,0) == "@") 1245 | return 0; 1246 | else if (cmd1 != "") 1247 | { 1248 | 1249 | { 1250 | if (llGetInventoryType(cmd1+".scr") == INVENTORY_NOTECARD) 1251 | { 1252 | ExecScriptLine(npcName , "run-notecard "+cmd1+".scr"); 1253 | } 1254 | else 1255 | llMessageLinked(LINK_THIS, -1, inputString, uNPC); 1256 | } 1257 | } 1258 | return 1; // 1 means that wait until next timer tick for next notecard command 1259 | } 1260 | 1261 | integer FindNewTarget(integer curNode, integer prevNode) 1262 | { 1263 | integer total=llGetListLength(wLinks); 1264 | candidateNode = []; 1265 | integer i; 1266 | integer a; 1267 | integer b; 1268 | for (i=0; i< total; i+=2) 1269 | { 1270 | a = llList2Integer(wLinks,i); 1271 | b = llList2Integer(wLinks,i+1); 1272 | if (a == curNode && prevNode != b) /// dont go back where we came from 1273 | candidateNode += b; 1274 | else if (b == curNode && prevNode !=a) 1275 | candidateNode += a; 1276 | } 1277 | 1278 | integer l = llGetListLength(candidateNode); 1279 | if (l>0) 1280 | { 1281 | return llList2Integer(candidateNode, (integer)llFrand((float)l)); 1282 | } 1283 | else 1284 | return prevNode; // go back to where we came from if there is no other option 1285 | } 1286 | 1287 | 1288 | integer MoveToNewTarget(integer idx) 1289 | { 1290 | integer curNode = llList2Integer(aviNodes,idx); 1291 | integer prevNode = llList2Integer(aviPrevNodes,idx); 1292 | 1293 | key uuid = llList2Key(aviUids, idx); 1294 | if (uuid == NULL_KEY) return 1; 1295 | vector pos = osNpcGetPos(uuid); 1296 | osNpcStand(uuid); 1297 | 1298 | vector wp = llList2Vector(wNodes, curNode); 1299 | float dist = llVecDist(pos, wp); 1300 | if (dist>10) osTeleportAgent(uuid, wp, <1,1, 7.1>); 1301 | 1302 | integer nt = FindNewTarget(curNode, prevNode); 1303 | if (nt <0) return 0; 1304 | vector tgt = llList2Vector(wNodes, nt); 1305 | // Try to stay in the right 'lane' 1306 | vector rr = 0.5*llVecNorm(tgt - pos)*llEuler2Rot(<0,0,-PI/2>); 1307 | tgt += rr; 1308 | osSetSpeed(uuid, 0.5); 1309 | osNpcMoveToTarget(uuid, tgt, OS_NPC_NO_FLY); 1310 | SetScriptAlarm(idx, GetWalkTime( llVecDist(wp, tgt) )+4); 1311 | aviNodes = []+llListReplaceList(aviNodes, [nt], idx, idx); 1312 | aviPrevNodes = []+llListReplaceList(aviPrevNodes, [curNode], idx, idx); 1313 | return 0; 1314 | } 1315 | 1316 | 1317 | integer ExecScriptLine(string aviName, string scriptline) 1318 | { 1319 | // The token list expects the name of the avi twice. we use 0000 as the sending-uid identifier 1320 | string command = "! "+ (string)NULL_KEY +" " + aviName +" "+ aviName +" "+ scriptline; 1321 | // list tokens = llParseString2List(command, [" "], [] ); 1322 | return ProcessNPCCommand(command); 1323 | } 1324 | 1325 | 1326 | 1327 | string TimeAgo(integer time) 1328 | { 1329 | // time difference in seconds 1330 | integer now = llGetUnixTime(); 1331 | integer timeDifference = now - time; 1332 | // small bug fix for when timeDifference is 0 1333 | if (timeDifference == 0) 1334 | return "just now"; 1335 | 1336 | list periods = ["second", "minute", "hour", "day", "week", "month", "year", "decade"]; 1337 | 1338 | //the number equivalent to periods 1339 | list lenghts = [1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600]; 1340 | 1341 | integer v = llGetListLength(lenghts) - 1; 1342 | integer no; 1343 | 1344 | while((0 <= v) && (no = timeDifference/llList2Integer(lenghts, v) <= 1)) --v; 1345 | string output = llList2String(periods, v); 1346 | 1347 | //this will get the correct time in periods, then divide the timeDifference 1348 | integer ntime = timeDifference / llList2Integer(lenghts, llListFindList(periods, [output])); 1349 | 1350 | //if integer 'no' is not equal to 1 then it should have an s at the end 1351 | if(no != 1) 1352 | output += "s"; 1353 | 1354 | //This produces the finished output 1355 | output = (string)ntime + " "+ output + " ago"; 1356 | return output; 1357 | } 1358 | 1359 | giveCommands(integer n) 1360 | { 1361 | integer i; 1362 | string lstr = ""; 1363 | string kstr = ""; 1364 | list lnks; 1365 | for (i=0; i < llGetListLength(wayLinks); i+=2) 1366 | { 1367 | integer a = llList2Integer(wayLinks,i); 1368 | integer b = llList2Integer(wayLinks,i+1); 1369 | if (a == n) 1370 | { 1371 | lstr += (string)b+","; 1372 | lnks += (string)llList2Key(wayKeys,b); 1373 | } 1374 | else if (b == n) 1375 | { 1376 | lstr += (string)a+","; 1377 | lnks += (string)llList2Key(wayKeys,a); 1378 | } 1379 | } 1380 | 1381 | string wstr = (string)n+"|SETDATA|"+vec2str(llList2Vector(wayPoints, n)); 1382 | wstr += "|"+llList2String(wayNames, n)+"|"+lstr+"|0|"+llList2CSV(lnks); 1383 | //llOwnerSay(wstr); 1384 | llRegionSay(PEG_CHAN, wstr); 1385 | } 1386 | 1387 | 1388 | 1389 | default 1390 | { 1391 | 1392 | state_entry() 1393 | { 1394 | llSetText("NPCs", <1,1,1>,1.0); 1395 | llListenRemove(gListener); 1396 | gListener = llListen(channel, "", "", ""); 1397 | llOwnerSay("Listening on channel "+channel); 1398 | ReloadConfig(); 1399 | LoadMapData(); 1400 | timerRuns=0; 1401 | RescanAvis(); 1402 | greetedAvis = []; 1403 | scriptVars = []; 1404 | 1405 | if (autoLoadOnReset) 1406 | { 1407 | llSleep(10); 1408 | doLoadAll(); 1409 | llSleep(10); // Need to wait for their listeners attachments to start 1410 | doInitCmds(); 1411 | llSleep(10); 1412 | } 1413 | 1414 | llSetTimerEvent(TIMER_INTERVAL); 1415 | } 1416 | 1417 | touch_start(integer num) 1418 | { 1419 | 1420 | if (llDetectedKey(0) != llGetOwner()) return; 1421 | llDialog(llGetOwner(), "Welcome", menuItems, channel); 1422 | } 1423 | 1424 | 1425 | // This checks the statuses of all avis and performs commands accordingly 1426 | timer() 1427 | { 1428 | integer total = llGetListLength(aviUids); 1429 | integer g; 1430 | integer advanceScript; 1431 | list startedScripts = []; 1432 | if (curVisitors>0) 1433 | for (g=0; g < total ; g++) 1434 | { 1435 | advanceScript =0; 1436 | aviIndex = g; 1437 | npc = llList2Key(aviUids, g); 1438 | string status = llList2String(aviStatus, g); 1439 | 1440 | if (status == "follow" || status == "flyfollow") 1441 | { 1442 | // This NPC is following someone 1443 | integer stat=llGetAgentInfo(npc); 1444 | if (stat & AGENT_SITTING) 1445 | { 1446 | // We 've been sat. stop following 1447 | return; 1448 | } 1449 | 1450 | key who = llList2Key(aviFollow, g); 1451 | list userData = llGetObjectDetails(who, [OBJECT_POS, OBJECT_ROT]); 1452 | if (llGetListLength(userData) ==0) 1453 | { 1454 | // User left or died 1455 | aviStatus= []+llListReplaceList(aviStatus, [ "" ], g, g); 1456 | return; 1457 | 1458 | } 1459 | 1460 | rotation rot = llList2Rot(userData,1); 1461 | float ang = llFrand(1.0); 1462 | vector v = llList2Vector(userData,0) + <-1.9,0,0>*rot; 1463 | float dist = llVecDist(osNpcGetPos(npc), v); 1464 | 1465 | if (status == "follow" && dist>50.) 1466 | { 1467 | osTeleportAgent(npc, v, <1,1,1>); 1468 | } 1469 | else if (dist>4) 1470 | { 1471 | //osNpcStopMoveToTarget(npc); 1472 | if (osIsNpc(who)) 1473 | osSetSpeed(npc, .47); 1474 | else osSetSpeed(npc, 1.0); 1475 | if (status == "flyfollow") 1476 | osNpcMoveToTarget(npc, v+<0,0,2.>, OS_NPC_FLY ); 1477 | else 1478 | osNpcMoveToTarget(npc, v, OS_NPC_NO_FLY ); 1479 | } 1480 | } 1481 | else if (status == "wander") 1482 | { 1483 | if (llGetUnixTime() > llList2Integer(aviAlarm, g) +1) 1484 | { 1485 | integer curNode = llList2Integer(aviNodes, g); 1486 | integer i; 1487 | integer shouldMove =1; 1488 | llMessageLinked(LINK_THIS, -1, "WAYPOINT " + (string)curNode+" "+llList2String(aviNames, g), npc); 1489 | // avoid looping back to the same script while we are about to leave 1490 | if (llList2Integer(aviPrevNodes, g)>=0) 1491 | { 1492 | if (llListFindList(startedScripts, curNode)>=0) 1493 | { 1494 | // dont start the same script simultaneously 1495 | } 1496 | else 1497 | { 1498 | string ncName = "_"+curNode+".scr"; 1499 | if (llGetInventoryType(ncName) == INVENTORY_NOTECARD) 1500 | { 1501 | startedScripts+= curNode; 1502 | ExecScriptLine(llList2String(aviNames, g), "run-notecard "+ncName); 1503 | shouldMove =0; 1504 | } 1505 | } 1506 | } 1507 | 1508 | if (shouldMove>0) 1509 | { 1510 | MoveToNewTarget(g); 1511 | } 1512 | } 1513 | } 1514 | else if (status == "godfly") 1515 | { 1516 | // This NPC is flying around 1517 | if (llGetUnixTime() > llList2Integer(aviAlarm, g) +1) 1518 | { 1519 | vector nd = (vector)llList2String(flyTargets, (integer)llFrand(llGetListLength(flyTargets))); 1520 | integer flag = OS_NPC_FLY; 1521 | osSetSpeed(npc, 0.5); 1522 | integer theight = 10; 1523 | vector p = osNpcGetPos(npc); 1524 | SetScriptAlarm(g, GetWalkTime(llVecDist(p, nd))/2); 1525 | osNpcMoveToTarget(npc, nd + , flag); 1526 | 1527 | } 1528 | } 1529 | else if (status == "pathf") 1530 | { 1531 | // Pathfinding - this NPC is following the path to a destination 1532 | integer avits = llList2Integer(aviAlarm, g); 1533 | if (llGetUnixTime() > avits) 1534 | { 1535 | 1536 | vector p = osNpcGetPos(npc); 1537 | string path = llList2String(aviPath, g); 1538 | llOwnerSay("Path="+path); 1539 | list pnodes = llParseString2List(path, [":"], []); 1540 | if (llGetListLength(pnodes)<1) 1541 | { 1542 | osNpcSay(npc, "I have arrived"); 1543 | aviStatus = []+llListReplaceList(aviStatus, [ "" ], g, g); 1544 | // continue the script (if any), since we reached our destination 1545 | SetScriptAlarm(g, 0); 1546 | } 1547 | else 1548 | { 1549 | integer nextTgt = llList2Integer(pnodes, 0); 1550 | string ndleft = ":"+llDumpList2String( llList2List(pnodes, 1, llGetListLength(pnodes)), ":"); 1551 | aviPath = []+llListReplaceList(aviPath, [ ndleft ], g, g); 1552 | vector v = llList2Vector(wNodes, nextTgt); 1553 | SetScriptAlarm(g, GetWalkTime(llVecDist(p, v))); 1554 | osNpcMoveToTarget(npc, v + , OS_NPC_NO_FLY ); 1555 | } 1556 | } 1557 | return; 1558 | } 1559 | else if (status == "prompt") 1560 | { 1561 | // do nothing 1562 | jump nexttick; 1563 | } 1564 | 1565 | 1566 | // Execute the next script line if a script is active 1567 | integer stopNow=0; 1568 | integer k; 1569 | integer scriptIndex = llList2Integer(aviScriptIndex, g); 1570 | while ( scriptIndex>0 && stopNow==0 && k++<5) // execute up to 10 lines at once if possible 1571 | { 1572 | 1573 | //llOwnerSay("scriptIndex = "+ (string)scriptIndex); 1574 | integer tsAlarm = llList2Integer(aviAlarm, g); 1575 | if (tsAlarm >0 && llGetUnixTime() >= tsAlarm ) // The script should continue now 1576 | { 1577 | string scriptData = llList2String(aviScriptText, g); 1578 | string scriptline = GetScriptLine(scriptData, scriptIndex); 1579 | if (scriptline == "") // End of script 1580 | { 1581 | // This will prevent any further execution 1582 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [-1], g, g); 1583 | } 1584 | else 1585 | { 1586 | // Substitute sender with the prompt target, if any 1587 | string cmd = "! "+ (string)llList2Key(aviTarget, g) +" "+ llList2String(aviNames, g) +" "+ llList2String(aviNames, g) + " "+ scriptline; 1588 | stopNow = ProcessNPCCommand(cmd); 1589 | // Advance script pointer 1590 | scriptIndex = llList2Integer(aviScriptIndex, g); 1591 | aviScriptIndex = []+llListReplaceList(aviScriptIndex, [scriptIndex+1], g,g); 1592 | } 1593 | } 1594 | scriptIndex = llList2Integer(aviScriptIndex, g); 1595 | } 1596 | 1597 | @nexttick; 1598 | 1599 | llParticleSystem( 1600 | [ 1601 | PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_EXPLODE, 1602 | PSYS_SRC_BURST_RADIUS,0, 1603 | PSYS_SRC_ANGLE_BEGIN,0, 1604 | PSYS_SRC_ANGLE_END,0, 1605 | PSYS_SRC_TARGET_KEY,llGetKey(), 1606 | PSYS_PART_START_COLOR,<1.000000,0.000000,0.000000>, 1607 | PSYS_PART_END_COLOR,<1.000000,0.000000,0.000000>, 1608 | PSYS_PART_START_ALPHA,1, 1609 | PSYS_PART_END_ALPHA,0, 1610 | PSYS_PART_START_GLOW,0, 1611 | PSYS_PART_END_GLOW,0, 1612 | PSYS_PART_BLEND_FUNC_SOURCE,PSYS_PART_BF_SOURCE_ALPHA, 1613 | PSYS_PART_BLEND_FUNC_DEST,PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA, 1614 | PSYS_PART_START_SCALE,<0.500000,0.500000,0.000000>, 1615 | PSYS_PART_END_SCALE,<4.000000,4.000000,0.000000>, 1616 | PSYS_SRC_TEXTURE,"", 1617 | PSYS_SRC_MAX_AGE,0.5, 1618 | PSYS_PART_MAX_AGE,2, 1619 | PSYS_SRC_BURST_RATE,1, 1620 | PSYS_SRC_BURST_PART_COUNT,1, 1621 | PSYS_SRC_ACCEL,<0.000000,0.000000,0.000000>, 1622 | PSYS_SRC_OMEGA,<0.000000,0.000000,0.000000>, 1623 | PSYS_SRC_BURST_SPEED_MIN,0, 1624 | PSYS_SRC_BURST_SPEED_MAX,0, 1625 | PSYS_PART_FLAGS, 1626 | 0 | 1627 | PSYS_PART_EMISSIVE_MASK | 1628 | PSYS_PART_INTERP_COLOR_MASK | 1629 | PSYS_PART_INTERP_SCALE_MASK 1630 | ]); 1631 | 1632 | } 1633 | 1634 | timerRuns++; 1635 | if (timerRuns%20==0) 1636 | { 1637 | curVisitors = countVisitors(); 1638 | } 1639 | } 1640 | 1641 | listen(integer chan, string name, key id, string str) { // WARNING "id" is not the uid of the NPC-sender 1642 | 1643 | string mes = str; 1644 | integer x = llSubStringIndex(str, " "); 1645 | if (x >=0) mes = llGetSubString(str, 0,x-1); 1646 | 1647 | if (!(osIsNpc(llGetOwnerKey(id)) || llGetOwnerKey(id)==llGetOwner())) 1648 | { 1649 | llOwnerSay("Denied access to "+llKey2Name(id)); 1650 | return; 1651 | } 1652 | 1653 | //llOwnerSay("<<" + str); 1654 | if (mes == "!") // Something that has been sent from a Listener of attached to an NPC 1655 | { 1656 | ProcessNPCCommand(str); 1657 | return; 1658 | } 1659 | else if (mes =="FBALL") 1660 | { 1661 | // A poseball has been found. We have to check if it is transparent. If it is not, then we sit the NPC on it 1662 | list tok = llParseString2List(str, [" "] , [""]); 1663 | string npcname= llList2String( tok, 1); 1664 | integer idx = GetNPCIndex(npcname); 1665 | if (idx<0) return; 1666 | key unpc = llList2Key(aviUids, idx); 1667 | integer i; 1668 | key ball; 1669 | for (i=2; i < llGetListLength(tok);i++) 1670 | { 1671 | ball = llList2String(tok, i); 1672 | list prop = osGetPrimitiveParams(ball, [PRIM_COLOR, 0]); /// This only works we own the poseball 1673 | float alpha = 1.0; 1674 | if (llGetListLength(prop)>0) alpha = llList2Float(prop, 1); 1675 | if (alpha >0) 1676 | { 1677 | jump ballFound; 1678 | } 1679 | } 1680 | //llOwnerSay(npcname + ": All balls transparent"); 1681 | @ballFound; 1682 | if (ball != NULL_KEY) 1683 | { 1684 | osNpcStand(unpc); 1685 | osNpcStopMoveToTarget(unpc); 1686 | osNpcSit(unpc, ball, OS_NPC_SIT_NOW); 1687 | aviStatus = []+llListReplaceList(aviStatus, ["sitting"], idx, idx); 1688 | } 1689 | } 1690 | else if (mes == "SETVAR") 1691 | { 1692 | list tok = llParseString2List(str, [" "] , [""]); 1693 | setVar(llList2String(tok,1), llList2String(tok,2)); 1694 | } 1695 | else if (llGetSubString(mes, 0, 7) == "CLICKED|")// Message from map editor HUD 1696 | { 1697 | list ll = llParseString2List(str, ["|"] ,[]); 1698 | string cmd1 = llList2String(ll, 0); 1699 | integer num = llList2Integer(ll, 1); 1700 | if (curPoint!= num) 1701 | { 1702 | prevPoint = curPoint; 1703 | curPoint = num; 1704 | } 1705 | 1706 | list btns = ["Close", "LinkPegs", "UnlinkPegs", "SetName"]; 1707 | llDialog(llGetOwner(), "Current peg: "+ (string)curPoint+ " Previous: "+(string)prevPoint, btns, channel); 1708 | return; 1709 | } 1710 | else if (llGetSubString(mes, 0, 6) == "MRKKEY|") 1711 | { 1712 | list ll = llParseStringKeepNulls(str, ["|"] ,[]); 1713 | integer num = llList2Integer(ll, 1); 1714 | key k = llList2Key(ll, 2); 1715 | wayKeys = [] + llListReplaceList(wayKeys, [k], num,num); 1716 | 1717 | } 1718 | else if (llGetSubString(mes, 0, 6) == "MARKER|") 1719 | { 1720 | list ll = llParseStringKeepNulls(str, ["|"] ,[]); 1721 | string cmd1 = llList2String(ll, 0); 1722 | integer num = llList2Integer(ll, 1); 1723 | vector pos = llList2Vector(ll, 2); 1724 | key tk = llList2Key(ll, 4); 1725 | wayPoints = llListReplaceList(wayPoints, [pos], num,num); 1726 | 1727 | return; 1728 | } 1729 | else if (mes == "ShowPegDialog") 1730 | { 1731 | list btns = ["Close", "RezPegs", "SaveCards", "AddPeg", "DeletePeg", "LinkPegs", "UnlinkPegs", "ScanPegs", "ClearPegs", "SetName"]; 1732 | llDialog(llGetOwner(), "First peg: "+ (string)curPoint+ " Second peg: "+(string)prevPoint, btns, 68); 1733 | return; 1734 | } 1735 | 1736 | 1737 | if (id != llGetOwner()) return; // Admin commands follow 1738 | 1739 | if (mes == "SaveNPC") 1740 | { 1741 | llDialog(llGetOwner(), "Select NPC to save your appearance", llList2List(availableNames, 0,10)+ "more", channel); 1742 | 1743 | userInputState = "WAIT_APPNAME"; 1744 | } 1745 | else if (mes == "LoadNPC") 1746 | { 1747 | llDialog(llGetOwner(), "Select an NPC to load", llList2List(availableNames, 0,10)+"more", channel); 1748 | userInputState = "WAIT_AVINAME"; 1749 | } 1750 | else if (mes == "RemoveNPC") 1751 | { 1752 | llDialog(llGetOwner(), "Select an NPC to delete", llList2List(availableNames, 0,10)+ "more", channel); 1753 | userInputState = "WAIT_REMOVEAVI"; 1754 | } 1755 | else if (mes == "UpdateNPC") 1756 | { 1757 | llDialog(llGetOwner(), "Select an NPC to re-save appearance ", llList2List(availableNames, 0,10)+"more", channel); 1758 | userInputState = "WAIT_UPDATE"; 1759 | } 1760 | else if (mes == "RemoveAll") 1761 | { 1762 | avis = osGetAvatarList(); 1763 | llSay(0, llList2CSV(avis)); 1764 | howmany = llGetListLength(avis); 1765 | integer i; 1766 | for (i =0; i < howmany; i+=3) 1767 | { 1768 | if (osIsNpc(llList2Key(avis, i))) 1769 | { 1770 | list p = llParseString2List(llKey2Name(llList2Key(avis,i)), [" "], []); 1771 | doRemoveNpc(llList2String(p, 0)); 1772 | //osNpcStand(llList2Key(avis, i)); 1773 | //osNpcRemove(llList2Key(avis, i)); 1774 | } 1775 | } 1776 | aviUids = []; 1777 | aviNames = []; 1778 | } 1779 | else if (mes == "LoadAll") 1780 | { 1781 | llSetTimerEvent(0); 1782 | doLoadAll(); 1783 | llSetTimerEvent(TIMER_INTERVAL); 1784 | } 1785 | else if (mes == "InitCmds") 1786 | { 1787 | llSetTimerEvent(0); 1788 | doInitCmds(); 1789 | llSetTimerEvent(TIMER_INTERVAL); 1790 | } 1791 | else if (mes == "TimerOnOff") 1792 | { 1793 | timerRunning = !timerRunning; 1794 | llSetTimerEvent(TIMER_INTERVAL*timerRunning); 1795 | llOwnerSay("Timer="+(string)timerRunning); 1796 | } 1797 | else if (mes == "DumpData") 1798 | { 1799 | llOwnerSay("Names="+llList2CSV(aviNames)); 1800 | llOwnerSay("Status="+llList2CSV(aviStatus)); 1801 | llOwnerSay("Nodes="+llList2CSV(aviNodes)); 1802 | llOwnerSay("PrevNodes="+llList2CSV(aviPrevNodes)); 1803 | llOwnerSay("ScriptIndex="+llList2CSV(aviScriptIndex)); 1804 | llOwnerSay("Alarm="+llList2CSV(aviAlarm)); 1805 | llOwnerSay("Curvisitors="+(string)(curVisitors)+ " Timer=" +timerRunning+" timerRuns="+(string)timerRuns); 1806 | llOwnerSay("Vars="+llList2CSV(scriptVars)); 1807 | } 1808 | else if (mes == "ReConfig") 1809 | { 1810 | ReloadConfig(); 1811 | LoadMapData(); 1812 | } 1813 | else if (mes == "deflectTo") 1814 | { 1815 | list tok = llParseString2List(str, [" "] , [""]); 1816 | deflectToNode = GetNodeIndexByName(llToLower(llList2String(tok,1))); 1817 | llOwnerSay("Deflecting to #"+(string)deflectToNode); 1818 | } 1819 | else if (mes == "AddPeg") 1820 | { 1821 | vector v = llGetPos(); 1822 | list res = llGetObjectDetails(llGetOwner(), [OBJECT_POS]); 1823 | wayPoints += llList2Vector(res, 0); 1824 | llOwnerSay("Added point " + (string)(llGetListLength(wayPoints))); 1825 | llRezObject("peg", v, ZERO_VECTOR, ZERO_ROTATION, llGetListLength(wayPoints)-1); 1826 | giveCommands( llGetListLength(wayPoints)-1); 1827 | return; 1828 | } 1829 | else if (mes == "LinkPegs") 1830 | { 1831 | 1832 | integer i; 1833 | for (i=0; i < llGetListLength(wayLinks); i+=2) 1834 | { 1835 | integer a = llList2Integer(wayLinks,i); 1836 | integer b = llList2Integer(wayLinks,i+1); 1837 | if ((a == curPoint && b == prevPoint ) || (b == curPoint && a== prevPoint )) 1838 | { 1839 | llOwnerSay("Link exists"); 1840 | return; 1841 | } 1842 | } 1843 | wayLinks += curPoint; 1844 | wayLinks += prevPoint; 1845 | giveCommands(curPoint); 1846 | giveCommands(prevPoint); 1847 | } 1848 | else if (mes == "UnlinkPegs") 1849 | { 1850 | 1851 | integer i; 1852 | for (i=0; i < llGetListLength(wayLinks); i+=2) 1853 | { 1854 | integer a = llList2Integer(wayLinks,i); 1855 | integer b = llList2Integer(wayLinks,i+1); 1856 | if ((a == curPoint && b == prevPoint ) || (b == curPoint && a== prevPoint )) 1857 | { 1858 | wayLinks = llListReplaceList(wayLinks, [], i, i+1); 1859 | giveCommands(a); 1860 | giveCommands(b); 1861 | } 1862 | } 1863 | } 1864 | else if (mes == "ClearPegs") 1865 | { 1866 | llRegionSay(PEG_CHAN, "die"); 1867 | } 1868 | else if (mes == "ScanPegs") 1869 | { 1870 | llOwnerSay("Scanning pegs ordered"); 1871 | llRegionSay(PEG_CHAN, "REPORT"); 1872 | } 1873 | else if (mes == "SetName") 1874 | { 1875 | llTextBox(llGetOwner(), "Set Peg #"+(string)curPoint + " name to: ", channel); 1876 | userInputState="WAIT_PEGNAME"; 1877 | } 1878 | else if (mes == "RezPegs") 1879 | { 1880 | list lines = llParseString2List(osGetNotecard("__waypoints"), ["\n"], []); 1881 | integer i; 1882 | wayPoints =[]; 1883 | wayNames = []; 1884 | for (i=0; i < llGetListLength(lines); i++) 1885 | { 1886 | list line = llParseString2List(llList2String(lines, i), [","], []); 1887 | vector v = < llList2Float(line, 0), llList2Float(line, 1), llList2Float(line, 2) >; 1888 | string nname = llList2String(line, 3); 1889 | if (v != ZERO_VECTOR) 1890 | { 1891 | wayPoints += v; 1892 | wayNames += nname; 1893 | } 1894 | } 1895 | wayLinks = llParseString2List( llStringTrim(osGetNotecard("__links"), STRING_TRIM) , ["\n", ","], [" "]); 1896 | llOwnerSay(llList2CSV(wayLinks)); 1897 | llRegionSay(PEG_CHAN, "die"); 1898 | llSleep(0.5); 1899 | vector pos = llGetPos(); 1900 | for (i=0; i < llGetListLength(wayPoints); i++) 1901 | llRezObject("peg", pos, ZERO_VECTOR, ZERO_ROTATION, i); 1902 | llSleep(0.5); 1903 | for (i=0; i < llGetListLength(wayPoints); i++) 1904 | giveCommands(i); 1905 | } 1906 | else if (mes == "UpdatePegs") 1907 | { 1908 | integer i; 1909 | for (i=0; i < llGetListLength(wayPoints); i++) 1910 | giveCommands(i); 1911 | } 1912 | else if (mes == "SaveCards") 1913 | { 1914 | integer i=0; 1915 | string scriptText = ""; 1916 | if (llGetListLength(wayLinks)==0) 1917 | { 1918 | llOwnerSay("No links created! Not saving cards!"); 1919 | return; 1920 | } 1921 | for (i=0; i < llGetListLength(wayPoints); i++) 1922 | { 1923 | vector v = llList2Vector(wayPoints,i); 1924 | scriptText += (string)v.x+","+(string)v.y+","+(string)v.z + "," + llList2String(wayNames, i) + "\n"; 1925 | } 1926 | 1927 | string cardName = "__waypoints"; 1928 | if (llGetInventoryType(cardName)==INVENTORY_NOTECARD) 1929 | { 1930 | llRemoveInventory(cardName); 1931 | llSleep(0.5); 1932 | } 1933 | osMakeNotecard(cardName,scriptText); 1934 | llOwnerSay(cardName +" Saved"); 1935 | cardName = "__links"; 1936 | if (llGetInventoryType(cardName)==INVENTORY_NOTECARD) 1937 | { 1938 | llRemoveInventory(cardName); 1939 | llSleep(0.5); 1940 | } 1941 | scriptText = ""; 1942 | for (i=0; i < llGetListLength(wayLinks); i+=2) 1943 | scriptText += llList2String(wayLinks,i)+ ","+llList2String(wayLinks,i+1)+ ",\n"; 1944 | osMakeNotecard(cardName,scriptText); 1945 | llOwnerSay(cardName +" Saved"); 1946 | llSleep(1); 1947 | LoadMapData(); 1948 | } 1949 | else if (userInputState != "" && mes != "")// Process dialog commands 1950 | { 1951 | if (mes == "more") 1952 | { 1953 | llDialog(llGetOwner(), "Select an NPC", llList2List(availableNames, 11,-1), channel); 1954 | } 1955 | else 1956 | { 1957 | if (userInputState == "WAIT_APPNAME") 1958 | { 1959 | osAgentSaveAppearance(llGetOwner(), "APP_"+llToLower(mes)); 1960 | llSay(0, "Saved Appearance " + llGetOwner() + " -> APP_"+llToLower(mes)); 1961 | } 1962 | else if (userInputState == "WAIT_PEGNAME") 1963 | { 1964 | wayNames = [] + llListReplaceList(wayNames, [llStringTrim(mes, STRING_TRIM)],curPoint, curPoint); 1965 | giveCommands(curPoint); 1966 | llOwnerSay("Waypoint " +(string)curPoint+ " name='"+mes+"'"); 1967 | } 1968 | else if (userInputState == "WAIT_AVINAME") 1969 | { 1970 | doLoadNPC(mes, GetLastName(mes)); 1971 | 1972 | } 1973 | else if (userInputState == "WAIT_UPDATE") 1974 | { 1975 | integer idx = GetNPCIndex(mes); 1976 | if (idx >=0) 1977 | { 1978 | key uu = llList2Key(aviUids, idx); 1979 | osNpcSaveAppearance(uu, "APP_"+llToLower(mes)); 1980 | llOwnerSay("Updating APP_"+llToLower(mes) ); 1981 | } 1982 | else llOwnerSay("Not found "+mes); 1983 | } 1984 | else if (userInputState == "WAIT_REMOVEAVI") 1985 | { 1986 | doRemoveNpc(mes); 1987 | } 1988 | 1989 | userInputState=""; 1990 | } 1991 | } 1992 | } 1993 | 1994 | 1995 | link_message(integer lnk, integer num, string command, key npc) // This script is in the object too. 1996 | { 1997 | if (num != -1) // -1 means we sent it 1998 | { 1999 | ProcessNPCCommand(command); 2000 | } 2001 | } 2002 | 2003 | changed(integer change) 2004 | { 2005 | if (change & (CHANGED_REGION_START | CHANGED_OWNER | CHANGED_REGION)) 2006 | { 2007 | llResetScript(); 2008 | } 2009 | } 2010 | 2011 | } 2012 | 2013 | -------------------------------------------------------------------------------- /Extension.lsl: -------------------------------------------------------------------------------- 1 | /* Example extension script. 2 | * Extension commands are executed if (a) the command is not a built-in commands and (b) a notecard named .scr does not exist 3 | * The commands are implemented through the link_message below. 4 | */ 5 | 6 | string vec2str(vector v) //string without spaces 7 | { 8 | return "<"+(string)v.x+","+(string)v.y+","+(string)v.z+">"; 9 | } 10 | 11 | key getAgentByName(string firstName) 12 | { 13 | firstName = llToLower(firstName); 14 | list ag = osGetAvatarList(); 15 | integer howmany = llGetListLength(ag); 16 | integer i; 17 | for (i =0; i < howmany; i+=3) 18 | { 19 | string name = llList2String(ag, i+2); 20 | integer sep = llSubStringIndex(name, " "); 21 | if (llToLower(llGetSubString(name, 0,sep-1)) == firstName) 22 | { 23 | return llList2Key(ag, i); 24 | } 25 | } 26 | return NULL_KEY; 27 | } 28 | 29 | // This can be used to send a command back to the controller, e.g. ControllerDo("Bob", "say i am an NPC"); 30 | ControllerDo(string npcName, string msg) 31 | { 32 | llMessageLinked(LINK_THIS, 0, "! "+(string)NULL_KEY+" "+npcName+" " +npcName+ " "+msg, NULL_KEY); 33 | } 34 | 35 | 36 | default 37 | { 38 | link_message(integer lnk, integer num, string command, key uNPC) // This script is in the object too. 39 | { 40 | if (num!=-1) return;/// Only process what the controller sent 41 | 42 | list tokens = llParseString2List(command, [",", " "], [] ); 43 | 44 | if (llList2String(tokens,0) == "!") 45 | { 46 | // The commands are of the form "! Bob Bob follow me" (notice the name of the NPC given twice) 47 | 48 | string sendUid = llList2String(tokens,1); 49 | string npcName = llToLower(llList2String(tokens,2)); 50 | 51 | string name2 = llToLower(llList2String(tokens,3)); 52 | string cmd1 = llList2String(tokens, 4); 53 | string cmd2 = llList2String(tokens, 5); 54 | 55 | 56 | if (cmd1=="hide" || cmd1 == "show") 57 | { 58 | // This can be used to hide-show attachments in the hands that use the ClothesListener script. 59 | osMessageAttachments(uNPC, cmd2+"-"+cmd1, [OS_ATTACH_MSG_ALL], 0); 60 | } 61 | else if (cmd1 == "help") 62 | { 63 | osNpcSay(uNPC, "Say '"+ npcName+ " ', where can be: 'follow ', 'fly with me', 'use', 'go to', 'dance', 'stand', 'stop', 'light', 'leave'."); 64 | } 65 | else if (cmd1 == "go") //walk back (b) forward (f) right (r) or left (l) 66 | { 67 | 68 | rotation r = osNpcGetRot(uNPC); 69 | vector v = osNpcGetPos(uNPC); 70 | float mf = (float)cmd2; 71 | if (mf <=0) mf = 1.; // Default one meter 72 | vector m; 73 | if (cmd2 == "f") m = <1,0,0>; 74 | else if (cmd2 == "b") m = <-1,0,0>; 75 | else if (cmd2 == "l") m = <0,1,0>; 76 | else if (cmd2 == "r") m = <0,-1,0>; 77 | 78 | osNpcMoveToTarget(uNPC, v + mf*m*r, OS_NPC_NO_FLY ); 79 | } 80 | else if (cmd1 == "runaround") 81 | { 82 | // The Npc will start to aimlessly run around in the specified radius (default 5m). Example: "Bob runaround 10" 83 | float rad = (float)cmd2; 84 | if (rad <=0) rad = 5; 85 | vector v = osNpcGetPos(uNPC); 86 | ControllerDo(npcName, "batch @loop; runtovr "+vec2str(v-)+" " + vec2str(v+)+"; jump loop"); 87 | } 88 | 89 | else if (cmd1 == "fetch") 90 | { 91 | // Used to teleport a user near you . Example: "Bob fetch alice" . Requires osTeleportAgent permissions 92 | key u = getAgentByName(cmd2); 93 | 94 | if (u != NULL_KEY) 95 | { 96 | list userData=llGetObjectDetails((key)sendUid, [OBJECT_NAME,OBJECT_POS, OBJECT_ROT]); 97 | vector v= llList2Vector(userData, 1); 98 | osTeleportAgent(u, v + <0,0,1>, <0,0,0>); 99 | } 100 | 101 | } 102 | else if (cmd1 == "daytime") 103 | { 104 | // Sets the time of day . E.g. "Bob daytime 1". Say "Bob daytime off" to revert to region default 105 | float dt = (float)cmd2; 106 | if (cmd2 =="off") 107 | { 108 | osSetRegionSunSettings( FALSE, FALSE, 0 ); 109 | osNpcSay(uNPC," Setting day time to default"); 110 | } 111 | else 112 | { 113 | osSetRegionSunSettings( FALSE, TRUE, (float)(dt) ); 114 | osNpcSay(uNPC," Setting day time to "+(string)dt+"h"); 115 | } 116 | } 117 | else 118 | { 119 | /* Unknown command */ 120 | 121 | } 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Greeter.lsl: -------------------------------------------------------------------------------- 1 | /* Simple greeter script that checks for visitors. If a new, previously unseen visitor is found, 2 | it sends a number of commands to an NPC. The commands teleport the NPC in front of the user, and say a welcome message. 3 | */ 4 | 5 | list seen = []; 6 | list already = []; 7 | 8 | string vec2str(vector v) 9 | { 10 | return "<"+v.x+","+v.y+","+v.z+">"; 11 | } 12 | 13 | checkVisitors() 14 | { 15 | list avis = llGetAgentList(AGENT_LIST_REGION, []); 16 | integer howmany = llGetListLength(avis); 17 | integer i; 18 | for ( i = 0; i < howmany; i++ ) { 19 | if ( ! osIsNpc(llList2Key(avis, i)) ) 20 | { 21 | key u = llList2Key(avis, i); 22 | if (llListFindList(seen, [u])<0) 23 | { 24 | 25 | list ud =llGetObjectDetails(u, [OBJECT_NAME,OBJECT_POS, OBJECT_ROT]); 26 | vector v = llList2Vector(ud, 1); 27 | rotation r = llList2Rot(ud, 2); 28 | 29 | string scr; 30 | if ( llListFindList(already, [u])<0) 31 | { 32 | 33 | // These are the notecard commands, separated by ';' which position the NPC, and say a welcome message. You can change the commands 34 | scr = "teleport "+vec2str(v+<2,0,0>*r) +"; stop; lookat "+vec2str(v)+"; anim bow; say Welcome to My Region! If you need help, say 'Magnus help'. Enjoy your stay!; wait 50; leave"; 35 | 36 | llRegionSay(68, "! 00000000-0000-0000-0000-000000000000 magnus magnus batch "+scr); 37 | already += u; 38 | } 39 | } 40 | } 41 | } 42 | seen = avis; 43 | } 44 | 45 | 46 | default 47 | { 48 | state_entry() 49 | { 50 | llSetTimerEvent(30); 51 | checkVisitors(); 52 | } 53 | timer() 54 | { 55 | checkVisitors(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Listener.lsl: -------------------------------------------------------------------------------- 1 | string chatKey = ""; 2 | string NPCNAME="INVALID"; 3 | key npc = NULL_KEY; 4 | integer gListener=-1; 5 | integer zListener=-1; 6 | integer aviNameLength; 7 | string status = ""; 8 | integer lightOn = 0; 9 | list talkedUids; 10 | string lastAnim=""; 11 | 12 | 13 | InitListener() 14 | { 15 | 16 | key id = llGetOwner(); 17 | if (id) 18 | { 19 | string name= llKey2Name(llGetOwner()); 20 | NPCNAME = llGetSubString(name, 0, llSubStringIndex(name, " ") - 1); 21 | if (zListener <0) 22 | { 23 | zListener = osListenRegex(0, "", "", "^(?i)(hi|hello|"+NPCNAME+" )(?-i)", OS_LISTEN_REGEX_MESSAGE); 24 | //llOwnerSay("Listening for '"+NPCNAME+"'"); 25 | } 26 | } 27 | } 28 | 29 | 30 | // Event handlers 31 | default 32 | { 33 | state_entry() 34 | { 35 | // script was reset while already attached 36 | if (llGetAttached() != 0) { 37 | InitListener(); 38 | } 39 | } 40 | 41 | on_rez(integer i) { 42 | llResetScript(); 43 | 44 | } 45 | 46 | 47 | 48 | listen(integer chan, string name, key id, string mes) 49 | { 50 | llRegionSay(68, "! "+(string)id+ " " +NPCNAME+ " "+mes); 51 | } 52 | 53 | dataserver(key qid, string mes) 54 | { 55 | if (mes == "find-balls") 56 | { 57 | llSensor("~ball3", "", SCRIPTED, 16, PI); 58 | llSensor("~ball2", "", SCRIPTED, 16, PI); 59 | llSensor("~ball1", "", SCRIPTED, 16, PI); 60 | llSensor("~ball0", "", SCRIPTED, 16, PI); 61 | status="looking1"; 62 | } 63 | else if (llGetSubString(mes, 0,1) == "do") 64 | { 65 | string bn = llGetSubString(mes, 3, llStringLength(mes)); 66 | llSensor(bn, "", SCRIPTED, 16, PI); 67 | status="looking2"; 68 | } 69 | else if (llGetSubString(mes, 0,6) == "lookfor") 70 | { 71 | string bn = llGetSubString(mes, 3, llStringLength(mes)); 72 | llSensor(bn, "", ACTIVE, 30, PI); 73 | status="looking2"; 74 | } 75 | else if (llGetSubString(mes, 0,4) == "sound") 76 | { 77 | list tok = llParseString2List(mes, [" "], []); 78 | llPlaySound(llList2Key(tok,1), llList2Float(tok,2)); 79 | } 80 | else if (llGetSubString(mes, 0, 4) == "light") 81 | { 82 | lightOn = !lightOn; 83 | llSetPrimitiveParams([PRIM_POINT_LIGHT, lightOn, <0.973, 0.543, 0.055>, 1.0, 20.0, 0.1]); 84 | } 85 | else if (llGetSubString(mes, 0, 3) == "anim") 86 | { 87 | llStopAnimation(lastAnim); 88 | integer sep = llSubStringIndex(mes, ":"); 89 | integer dur = (integer)llGetSubString(mes, 5, sep); 90 | 91 | lastAnim = llGetSubString(mes, sep+1, llStringLength(mes)); 92 | llOwnerSay("Playing /" + lastAnim+"/"); 93 | llStartAnimation(lastAnim); 94 | llSetTimerEvent(dur); 95 | } 96 | 97 | } 98 | 99 | sensor(integer detected) 100 | { 101 | 102 | list det = []; 103 | integer i; 104 | for (i=0;i < detected; i++) 105 | { 106 | key k = llDetectedKey(i); 107 | det += k; 108 | } 109 | llRegionSay(68, "FBALL "+NPCNAME+" "+llDumpList2String(det," ")); 110 | } 111 | 112 | timer() 113 | { 114 | llStopAnimation(lastAnim); 115 | llSetTimerEvent(0); 116 | } 117 | 118 | } 119 | 120 | -------------------------------------------------------------------------------- /NotecardMakerHUD.lsl: -------------------------------------------------------------------------------- 1 | integer channel; 2 | integer listener = -1; 3 | string status; 4 | list btns ; 5 | key owner; 6 | 7 | string cardName = "_script.scr"; 8 | 9 | string scriptText; 10 | 11 | list order_buttons(list buttons) 12 | { 13 | return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + 14 | llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10); 15 | } 16 | 17 | string anim = ""; 18 | integer menuindex; 19 | 20 | DialogPlus(key avatar, string message, list buttons, integer channel, integer CurMenu) 21 | { 22 | if (12 < llGetListLength(buttons)) 23 | { 24 | list lbut = buttons; 25 | list Nbuttons = []; 26 | if(CurMenu == -1) 27 | { 28 | CurMenu = 0; 29 | menuindex = 0; 30 | } 31 | 32 | if((Nbuttons = (llList2List(buttons, (CurMenu * 10), ((CurMenu * 10) + 9)) + ["<<", ">>"])) == ["<<", ">>"]) 33 | { 34 | menuindex =0; 35 | DialogPlus(avatar, message, lbut, channel, menuindex); 36 | } 37 | else 38 | llDialog(avatar, message, order_buttons(Nbuttons), channel); 39 | } 40 | else 41 | llDialog(avatar, message, order_buttons(buttons), channel); 42 | } 43 | 44 | showDialog() 45 | { 46 | btns = ["Close", "movetov", "AddCode", "Clear", "SaveCard", "Reload"]; 47 | llDialog(llGetOwner(), "Current Script: \n"+llGetSubString(scriptText, -480, -1), btns, channel); 48 | } 49 | 50 | startListen() 51 | { 52 | channel = -1 - (integer)("0x" + llGetSubString( (string) llGetOwner(), -6, -1) ) - 12313 ; 53 | llListen(channel, "","",""); 54 | } 55 | 56 | default 57 | { 58 | state_entry() 59 | { 60 | llSetText("Notecard Editor", <1,1,1>, 1.0); 61 | startListen(); 62 | 63 | } 64 | 65 | 66 | attach(key u) 67 | { 68 | startListen(); 69 | } 70 | 71 | on_rez(integer n) 72 | { 73 | llResetScript(); 74 | } 75 | 76 | touch_start(integer num) 77 | { 78 | 79 | showDialog(); 80 | status = ""; 81 | } 82 | 83 | listen(integer chan, string who, key id, string msg) 84 | { 85 | if (status == "entertext") 86 | { 87 | scriptText = llStringTrim(scriptText, STRING_TRIM) + "\n"+msg+"\n"; 88 | status = ""; 89 | } 90 | else if (msg == "movetov" ) 91 | { 92 | 93 | list res = llGetObjectDetails(llGetOwner(), [OBJECT_POS]); 94 | scriptText += "movetov " +(string)llList2Vector(res,0) + "\n"; 95 | llOwnerSay("movetov " +(string)llList2Vector(res,0) ); 96 | 97 | } 98 | else if (msg == "AddCode") 99 | { 100 | llTextBox(llGetOwner(), "" +llGetSubString(scriptText, -120,-1)+ "\nAdd code:" , channel); 101 | status = "entertext"; 102 | return; 103 | } 104 | else if (msg == "Clear") 105 | { 106 | scriptText = ""; 107 | } 108 | else if (msg == "Reload") 109 | { 110 | scriptText = osGetNotecard(cardName); 111 | } 112 | else if (msg == "SaveCard") 113 | { 114 | 115 | if (llGetInventoryType(cardName)==INVENTORY_NOTECARD) 116 | { 117 | llRemoveInventory(cardName); 118 | llSleep(0.25); 119 | } 120 | osMakeNotecard(cardName,scriptText); 121 | llOwnerSay("Card Saved"); 122 | } 123 | else if (msg == "Close") 124 | { 125 | return; 126 | } 127 | showDialog(); 128 | } 129 | 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /Peg.lsl: -------------------------------------------------------------------------------- 1 | /* The Peg script for waypoint management */ 2 | 3 | integer num; 4 | string notecard; 5 | list links; 6 | integer channel; 7 | string name; 8 | string status; 9 | vector pos; 10 | integer zListener; 11 | integer gListener; 12 | integer PEG_CHAN=699; 13 | integer CONTROLLER_CHAN=68; 14 | 15 | 16 | default 17 | { 18 | on_rez(integer m) 19 | { 20 | num = m; 21 | llSetText("Uninitialized", <1,1,1>, 1.0); 22 | //zListener = llListen(channel, "","",""); 23 | gListener = llListen(PEG_CHAN, "","",""); 24 | } 25 | 26 | touch_start(integer n) 27 | { 28 | string str="Peg Num:"+(string)num+"\nName:"+name+"\nLinks:"+llList2CSV(links)+"\nNotecard:"+notecard; 29 | //llOwnerSay(str); 30 | llRegionSay(CONTROLLER_CHAN, "CLICKED|"+num); 31 | //llDialog(llGetOwner(), " "+ str, ["Name", "Links", "Notecard"], channel); 32 | } 33 | 34 | listen(integer chan, string wname, key id, string data) 35 | { 36 | if (data == "die") 37 | { 38 | llDie(); 39 | } 40 | else if (data == "REPORT") 41 | { 42 | string str = "MARKER|"+(string)num+"|"+(string)llGetPos()+"|"+name+"|"+(string)llGetKey(); 43 | llRegionSay(CONTROLLER_CHAN, str); 44 | } 45 | 46 | list l = llParseStringKeepNulls(data, ["|"], []); 47 | if ((integer)llList2String(l,0) != num) return; 48 | 49 | string cmd = llList2String(l,1); 50 | 51 | if (cmd == "SETDATA") 52 | { 53 | pos = (vector)llList2String(l, 2); 54 | name = llList2String(l, 3); 55 | string lstr = llList2String(l, 4); 56 | notecard = llList2String(l, 5); 57 | links = llParseString2List(lstr, [","],[]); 58 | llSetRegionPos(pos); 59 | llSetText("Num="+(string)num+"\nName="+name+"\nLinks:"+llList2CSV(links), <1,0,0>, 1.0); 60 | } 61 | 62 | } 63 | } 64 | 65 | 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ActiveNPCs NPC Controller 2 | 3 | This is a full-featured controller for creating interactive NPCs , scripting them (through notecards) and creating waypoints of your region so that the NPCs can walk around your region. The controller is extremely lightweight (a single script manages all the NPCs) and the NPCs are interactive (i.e. you can give them commands through the local chat). 4 | 5 | You can get the latest package from the OpenSimWorld region: 6 | 7 | http://opensimworld.com/hop/74730-OpenSimWorld 8 | 9 | Hypergrid: hg.osgrid.org:80:OpenSimWorld 10 | 11 | 12 | Visit https://github.com/opensimworld/active-npcs/edit/master/README.md for an up-to-date version of this documentation. 13 | 14 | 15 | # Quickstart 16 | 17 | The controller requires OSSL functions to work. You need to have permission to use the osNpc*() functions and, additionally: , osGetNotecard(), osGetNotecardLines(), osMessageAttachments(), osSetSpeed(). The controller uses the channel 68 to communicate. 18 | 19 | To start using the controller: 20 | - Rez the OSW NPC Controller object somewhere in your region. Make sure your avatar is within distance of 20m or less from the controller 21 | - Wear the OSW NPC Listener object (it should attach automatically to your Right Pec!) 22 | - Edit the `__npc_names` notecard, and place first name and last names of each of your NPCs in a line by itself. Example: 23 | ``` 24 | Bob TheRobot 25 | Alice TheNPC 26 | ``` 27 | - Touch the controller -> ReConfig 28 | - Touch the controller, SaveNPC -> Bob (You should see a message "Saved appearance xxx-xxx -> APP_bob" 29 | - Touch the controller -> LoadNPC -> Bob 30 | 31 | Your npc should now be responding to commands , e.g. "Bob come" 32 | 33 | 34 | # Controller object Contents 35 | 36 | * The controller script (..Controller). This is the single script that runs everything. 37 | * An example extension script (..Extension). This can be used to add commands to the system (explained below). 38 | * The Listener object. All our NPCs must wear this invisible object on their Right Pec. This object listens for commands from the local chat and forwards them to the controller script for processing. 39 | * The __npc_names notecard. This notecard contains the names of the NPCs, one in each line . After making changes to this notecard, select "Reconfig" from the controller menu. 40 | * The __initcommands notecard. This is a notecard with the commands that are executed when you click "InitCmds" on the controller menu. 41 | * The __waypoints notecard. This contains a list of points in your region. The NPCs can walk from one point to the other, if they are connected (via the __links notecard) . *You do not need to edit this by hand. There is an HUD for editing the map* 42 | * The __links notecard. This contains a list of pairs of connected points. I.e. if you want to link point 1 to point 2, there will be a line "1,2" in the notecard. *You do not need to edit this by hand. There is an HUD for editing the map* 43 | * The __config notecard. This contains configuration ootions. 44 | * Command notecards. You can put any list of commands for NPCs a notecard named [command-name].scr. You can then order your NPCs to execute the notecards from the local chat. E.g. if you create a notecard "dance.scr", you can say "Bob dance" to execute it. 45 | * Waypoint notecards. Notecards named _1.scr , _2.scr etc are executed automatically when the NPCs reach the waypoint number 1, number 2 etc. 46 | * The appearance notecards are stored as APP_[firstname] for each NPC. You can also have multiple appearances per NPC (see below). 47 | * The Waypoint HUD is used to edit the map and create/update the __waypoints and __links notecards 48 | 49 | # Overview of commands 50 | 51 | The NPCs respond to commands that you give to them through the local chat. 52 | 53 | Assuming your NPC is named "Bob", you can say the following in the local chat: 54 | ``` 55 | Bob come 56 | Bob leave 57 | Bob stop 58 | Bob follow me 59 | Bob fly with me 60 | Bob say hi 61 | ... 62 | etc. 63 | ``` 64 | You can put these commands in notecards in order to create complex scenarios. 65 | 66 | For more complex behavior, the following control commands are supported in notecards: if, if-not, jump 67 | 68 | Example of a scenario notecard: 69 | ``` 70 | if name-is Bob Alice 71 | say hi 72 | say I am either Bob or Alice 73 | jump outofhere 74 | end-if 75 | say i am not bob or alice 76 | @outofhere 77 | if-not name-is Bob 78 | say I am definitely not Bob 79 | end-if 80 | say ... and i 'm now leaving 81 | leave 82 | ``` 83 | You can add these commands to a notecard named "test.scr" inside the controller object, and then ask the Bob to execute them by saying "Bob test" in the local chat. 84 | 85 | 86 | # List of NPC commands 87 | 88 | When giving commands through the local chat, commands must be preceded by the first name of the NPC. Here we assume our NPC is called "Bob" 89 | ``` 90 | Bob come : "Come here ". Bob will move close to you 91 | 92 | Bob moveto 23 : Walk towards waypoint #23 93 | 94 | Bob movetov <23,24,25> : walk towards point with coordinates <23,24,25> (Note, no spaces between vector coordinates) 95 | 96 | Bob runtov <23,24,25> : run towards point with coordinates <23,24,25> 97 | 98 | Bob flytov <23,24,25> : fly towards point <23,24,25> in region 99 | 100 | Bob movetovr <23,24,25> <33,34,25> : walk to a random point between the points <23,24,25> <33,34,25> 101 | 102 | Bob runtovr <23,24,25> <33,34,25> : same as above, but run 103 | 104 | ``` 105 | * * Note: never leave spaces in coordinate vectors, i.e. <23,24,25> NOT <23, 24, 25> ** 106 | 107 | ``` 108 | Bob say hi : Says "hi" on public channel 109 | 110 | Bob saych 90 blablah : say "blablah" on channel 90 111 | 112 | Bob shout Blah bleh 113 | 114 | Bob teleport <23,30,40> : Teleports to a point. REMEMBER: no spaces inside the vector brackets 115 | 116 | Bob lookat me : attempts to look at you 117 | 118 | Bob lookat : look towards point x,y,z 119 | 120 | 121 | Bob anim dance : play animation "dance" . the animation must be in the inventory of the controller object 122 | 123 | Bob sound 1c8a3af2-6e5a-4807-a7a3-a42e5744217c 1.0 : The NPC will trigger the sound with the given UUID at the volume specified by the second parameter (1.0 is max volume) 124 | 125 | Bob light : turn on/off a light the NPCs have on them 126 | 127 | Bob give Apple : Give the object "Apple" from the controller's inventory to the user. For security, only Objects can be given. 128 | 129 | Bob follow me 130 | 131 | Bob follow Alice : follow the avatar whose first name is 'Alice' 132 | 133 | Bob fly with me 134 | 135 | Bob fly with alice : fly with another user 136 | 137 | Bob stop : Stops his animation and his movement, and stops following you 138 | ``` 139 | 140 | ### Waypoint and Pathfinding commands 141 | You need to have set up the map of your region for these commands. That is described elsewhere. The NPC can automatically try to find how to walk from waypoint A to B. Because this is computationally intensive, only paths with less than 15 connections between them are supported. 142 | 143 | ``` 144 | Bob leave : Start walking randomly between connected waypoints 145 | 146 | Bob teleport Bar : Teleports bob to the waypoint named "Bar" 147 | 148 | Bob lookat Bar : look towards the waypoint named "Bar" 149 | 150 | Bob moveto 1 : Walk to waypoint #1 151 | 152 | Bob nearest : Tell me which is the nearest waypoint 153 | 154 | Bob setpath 0:1:3:5:1:0 : Walk through the given waypoints, i.e. walk to waypoint 0 , then to 1, then to 3, then to 5 etc. 155 | 156 | Bob goto 13 : Will walk between connected waypoints to waypoint #13 157 | 158 | Bob go to Bar : Will walk between connected waypoints to the waypoint named "Bar" 159 | : BEWARE! "goto" and "go to" (with space) are different commands 160 | Bob go to : without a destination, Bob will print the names of waypoints he knows 161 | 162 | ``` 163 | 164 | ## Command Notecards 165 | Multiple commands can be appended to a notecard, and then the NPC can execute them. 166 | ``` 167 | Bob run-notecard my_script.scr : Execute the contents of the notecard my_script.scr (the notecard must be in the controller inventory 168 | 169 | Bob my_script : Simpler syntax. Same as run-notecard: Starts executing the notecard "my_script.scr" 170 | 171 | Bob batch say hi ; wait 10; say bye : Executes multiple commands one after the other. Commands are separated by ";" The commands will be executed as if they were in a notecard 172 | 173 | Bob stop-script : Stop executing the notecard script 174 | 175 | ``` 176 | 177 | ## Multiple appearances 178 | 179 | You can have multiple appearance notecards for an NPC by renaming them. The default notecard for NPC Bob is stored in the APP_bob notecard. You can rename the notecard to, e.g. APP_bob_swimming, and then ask bob to load that notecard: 180 | 181 | ``` 182 | Bob dress swimming : load the appearance from notecard "APP_bob_swimming" 183 | 184 | Bob dress : load the NPC's default appearance from notecard "APP_bob" 185 | ``` 186 | 187 | 188 | ## Sitting on objects 189 | 190 | The NPCs can sit on objects with the "use" command. 191 | ``` 192 | Bob use chair 193 | ``` 194 | Bob will attempt to find a SCRIPTED object (e.g. a poseball) named "chair" (You can change the Object Name from the properties box when editing it) near him and try to sit on it if its transparency (alpha) is less than 100%. Since by convention poseballs change their transparency to 100% when users sit on them, this ensures that Bob will not sit on an already-occupied poseball. If you just say "Bob use", the NPC will sit on the nearest scripted object. 195 | 196 | ``` 197 | Bob stand : Bob will stand up if he is sitting 198 | ``` 199 | 200 | 201 | ## Variables 202 | Variables can be used with IF commands in notecards for more complex behavior.Variables are global and shared between notecards and NPCs. 203 | ``` 204 | Bob setvar foo 13 : set variable foo to be "13". Only string variables are supported. Variables can be used with IF blocks 205 | 206 | Bob setvar foo : set variable foo to the empty string. (The empty string is the default value if a variable does not exist) 207 | 208 | Bob say $foo : Bob says "13" 209 | 210 | if var-is foo 13 211 | say foo is thirteen 212 | end-if 213 | if var-is foo 214 | say foo is empty string or not set 215 | end-if 216 | 217 | waitvar foo 13 : wait (and do nothing) until the variable foo becomes 13 218 | ``` 219 | 220 | The following commands increase and decrease a variable by 1. They are useful in cases where you want 2 or more avatars to be present to proceed: 221 | ``` 222 | increase totalAvatarsHere : Increase the variable "totalAvatarsHere" by 1 223 | 224 | decrease totalAvatarsHere : Decrease the variable "totalAvatarsHere" by 1 225 | 226 | zero totalAvatarsHere : Set variable totalAvatarsHere to 0 (same as setvar totalAvatarsHere 0) 227 | ``` 228 | Example usage in a notecard: 229 | ``` 230 | increase totalAvatarsHere 231 | waitvar totalAvatasHere 2 232 | say Now there are 2 of us 233 | anim dance 234 | wait 10 235 | stop 236 | ... 237 | say Time to depart 238 | decrease totalAvatarsHere 239 | ``` 240 | 241 | 242 | ## IF commands 243 | There is support for multiple levels of IF blocks. Blocks must end with "end-if". There is no "else" command, but you can achieve the same effect with "jump" commands 244 | 245 | ``` 246 | if name-is bob alice : if the npc's name is Bob or alice 247 | say I am either Bob or Alice 248 | if-not name-is Bob 249 | say I must be Alice 250 | end-if 251 | end-if : always end IF blocks with end-if. You can nest if blocks 252 | 253 | if-not name-is Bob : Example of negative if 254 | say I am not Bob 255 | end-if 256 | 257 | if-prob 0.3 : IF block will be executed with probabilty 0.3 (the if block will be executed 30% of the time) 258 | say This will be heard 30% of the times 259 | end-if 260 | 261 | if var-is party 1 : Will execute the IF block if the variable party is "1" 262 | say We are having a party already! 263 | end-if 264 | 265 | if var-is party : Will execute the IF block if the variable party is empty or not set 266 | say No party yet, let's start one! 267 | setvar party 1 268 | end-if 269 | ``` 270 | 271 | Jump command. You can use the syntax @label to create labels in your notecards. The syntax is: 272 | ``` 273 | @myLabel : a label 274 | say This will loop forever 275 | jump myLabel : like "jump" in LSL or "goto" in other languages. the label should be on a line by itself prefixed with '@' 276 | 277 | ``` 278 | 279 | 280 | ## WAIT commands 281 | ``` 282 | wait 200 : wait (don't do anything) for 200 seconds 283 | 284 | wait 200 300 : wait between 200 and 300 second before executing the next command 285 | 286 | waitvar foo 13 : wait until the variable foo gets the value 13 287 | 288 | waitvar foo : wait until the variable foo is empty. 289 | 290 | ``` 291 | 292 | 293 | ## Other commands 294 | 295 | ``` 296 | Bob msgatt attachment_command 12 13 14 15 297 | ``` 298 | Uses osMessageAttachments to send the message "attachment_command" to attachments at attach points 12 13 14 15. 299 | This can be useful for scripting NPC attachments. Read the OSSL docs of osMessageAttachments() for more. 300 | 301 | 302 | ## Custom command notecards 303 | 304 | You can extend the list of commands with notecards. To create a command notecard, enter the commands for the NPC to execute in a notecard, and save it into the controller's inventory with the name [command-name].scr 305 | 306 | E.g. a dance command notecard would be named "dance.scr" and contain the following 307 | ``` 308 | say I love to dance! 309 | anim RockDance 310 | wait 600 800 311 | say oops, I am tired... 312 | stop 313 | ``` 314 | You can then say "Bob dance" to have bob execute the notecard 315 | 316 | 317 | ## Interactive menus 318 | 319 | With interactive menus, your NPCs can ask your visitors to make a choice from a menu in the local chat. The following notecard asks the user if they want apple or an orange and gives an object to them: 320 | 321 | ``` 322 | say Welcome to the shop! 323 | @prompt 324 | prompt Do you want an [apple] or an [orange]? 325 | say I didn't catch that. Starting over. 326 | jump prompt 327 | @apple 328 | say Here is an apple 329 | give Apple 330 | jump end 331 | @orange 332 | say Here is your orange 333 | give Orange 334 | jump end 335 | @end 336 | say Goodbye 337 | ``` 338 | 339 | Here is how it works: 340 | - The options of the menu are specified in the prompt string itself, in square brackets: 341 | ``` 342 | prompt Do you want an [apple] or an [orange]? 343 | ``` 344 | - Bob will say "Do you want an [apple] or an [orange]?" to the local chat, and it will expect to read the words "apple" or "orange" in the local chat from your visitor. 345 | - If he hears "apple", he will jump to the label "@apple" in the notecard. 346 | - If he hears "orange", he will jump to label "@orange" in the notecard. 347 | - If he hears something else, he will not jump, but continue normally to the next notecard line after the "prompt" line. (In our case, he asks again). 348 | - The menu options can only be single words (e.g. "orange", or "apple"). They are case-insensitive, and the menu will work even if the word is said in a phrase (I.e. "I want an apple" will still jump to @apple) 349 | 350 | 351 | 352 | 353 | ## Waypoints and Pathfinding 354 | 355 | You can use the controller to create waypoints and links between them in your region. Bob can then walk between the connected points when you say 'Bob leave' 356 | 357 | Each waypoint has a number (starting from 0) and optionally a name. Waypoints can be connected to other waypoints, thus creating a map (graph) between them. Bob can then wander between the waypoints (Say "Bob leave" to start walking), and you can also ask him to find his way from point A to point B (say Bob go to [destination]). 358 | 359 | The waypoint data are stored in the __waypoints notecard, one in each line, and the links data is stored in the __links notecard. You do not need to edit these notecards by hand however, as you can use the included Waypoint Editor HUD. 360 | 361 | To create a map, first wear the WaypointEditor HUD. If you already have created a map before, click RezPegs from the HUD menu. This will rez a peg in each waypoint you have already created. If you are starting with an empty map, you do not need to do this. 362 | 363 | To add a waypoint, move your avatar to the desired position, and select "AddPeg" from the HUD menu. A peg should appear in front of you. To create a second waypoint, move to another position, and repeat. 364 | 365 | To link the two waypoints X and Y, click on the first one (X), then click on the second one (Y). The pop up dialog should say "Current peg: Y, previous: X". To link them, select "LinkPegs" from the popup dialog. To unlink two waypoints, again, click on the first one, then click on the second one and select "UnlinkPegs" from the popup. Be careful to disregard all other dialogs that have popped up. 366 | 367 | You can give a name to waypoints. Click the peg, select "SetName", and enter the name (E.g. "Bar"). You can use this name to give commands to your NPCs later (e.g. "Bob go to bar"). 368 | 369 | You can move the waypoints around to correct their positions. Important: After you move pegs to new positions click "ScanPegs" from the editor HUD. If you don't do this your changes will be lost. 370 | 371 | After you have created/edited your waypoints, click the WaypointEditor HUD and select "SaveCards". This will update/create the __waypoints and the __links notecards inside the controller to match your new map. To test that all went well, clear the pegs and rez them again. 372 | 373 | Note! Removing waypoints is not supported, as it would break the numbering and would mess up the notecard naming scheme. Although deleting is not supported, you can unlink a waypoint from all other waypoints, in which case the NPCs will never go there when wandering. If you want to start over with an empty map, edit the __waypoints and __links notecards, remove all their contents, and then select "Reconflg" from the controller. 374 | 375 | 376 | ## Configuration 377 | Configurable options for the controller are added in the __config notecard: 378 | ``` 379 | AutoLoadOnReset=0 380 | ``` 381 | Change AutoLoadOnReset=0 to AutoLoadOnReset=1 to make the controller rez the NPCs automatically on region restart or script reset. Please note that autoloading NPCs may not always work well with some opensim versions. 382 | 383 | 384 | 385 | ## Permissions 386 | 387 | Permissions allow you to limit access to NPCs , and to specific commands to certain users or to all users. An access control list is specified in the __permissions notecard which is inside the controller object. 388 | 389 | Each line in the __permissions notecard has the format 390 | ``` 391 | = 392 | ``` 393 | Where RULE is ALLOW, DENY, ALLOWID, DENYID or ALLOWSAMEGROUP (read below for usage). 394 | 395 | The following line blocks (denies) avatar "Bad Hombre" from issuing the "bob come" command: 396 | ``` 397 | bob come = DENY Bad Hombre 398 | ``` 399 | You can substitute the name of the NPC or the name of the command or the name of the avatar with the wildcard character '*'. 400 | for example, this blocks any avatar from using the command: 401 | ``` 402 | bob come = DENY * 403 | ``` 404 | you can block any avatar from issuing the "come" command to any NPC: 405 | ``` 406 | * come = DENY * 407 | ``` 408 | you can block any avatar from issuing any command to Bob: 409 | ``` 410 | Bob * = DENY * 411 | ``` 412 | you can block a specific avatar from using any command on any npc: 413 | ``` 414 | * * = DENY Bad Hombre 415 | ``` 416 | you can also use the DENYID command to block an avatar by UUID 417 | ``` 418 | * * = DENYID d37a3f5b-562a-4bfd-b780-68c0b9b940b1 419 | ``` 420 | and you can block any avatar from using any command with any NPC! 421 | ``` 422 | * * = DENY * 423 | ``` 424 | The rules specified in the notecard are executed from top to bottom, therefore you can add exceptions for specific users with the ALLOW and ALLOWID commands at the end of the list: 425 | ``` 426 | * come = ALLOW Good User 427 | * come = ALLOWID d37a3f5b-562a-4bfd-b780-68c0b9b940b1 428 | ``` 429 | You can also use the keyword ALLOWSAMEGROUP, which allows any avatar that is in the same group as the controller object. 430 | ``` 431 | * come = ALLOWSAMEGROUP 432 | ``` 433 | You can use the wildcard '*' with the ALLOW commands as well 434 | ``` 435 | Bob come = ALLOW * 436 | * come = ALLOW * 437 | Bob * = ALLOW * 438 | ``` 439 | 440 | An example __permissions notecard is given below which blocks any avatar from controlling the NPC "Alice" and disallows the "exec" command, but allows exceptions to certain users. It also blocks "evil user" from any command: 441 | ``` 442 | Alice * = DENY * 443 | * exec = DENY * 444 | Alice * = ALLOW Good User 445 | Alice * = ALLOWSAMEGROUP 446 | * exec = ALLOW Good User 447 | * exec = Allow Another Gooduser 448 | * * = DENY Evil User 449 | ``` 450 | 451 | - Note that the ALLOW, DENY, ALLOWID etc. rules need to be in CAPITALS. Also, There must always be a space before and after the '=' character. 452 | - The owner of the controller is always able to use all commands with all NPCs regardless of access list. 453 | - If you make changes to the __permissions notecard, please click on the controller ->ReConfig to reload the permissions list. 454 | 455 | 456 | ## Initialization commands 457 | The notecard __initcommands contains initial commands to give to the NPCs. If AutoLoadOnReset is enabled, the notecard contents are executed automatically after loading. You can also manually execute the notecard by clicking "InitCmds" from the controller menu. You can use the __initcommands to add any command that sets your NPCs in motion. Typically you would tell them to "leave" so that they start walking between waypoints. An example of __initcommands is : 458 | 459 | ``` 460 | Bob say I am rezzed! 461 | Bob teleport <64,64,22> 462 | Alice teleport <128,64,22> 463 | Bob leave 464 | Alice leave : Start walking! 465 | ``` 466 | 467 | 468 | ## Extension scripts 469 | 470 | You can extend the functionality of the controller with extension scripts. Extensions are LSL scripts that you create and add inside the controller object. If a command given to an NPCs is not understood by the NPC controller, the NPC controller will send a link_message to the extension scripts to process it. The extensions can also use link_message to send back commands to the NPC controller (the "number" parameter must be greater than 0) . The OSW NPC Controller object already contains an extension that implements the "help" command (look at the "..Extension" script). The script in it shows how extensions parse the data sent from the controller (sent through link_message) and how they can respond back. 471 | 472 | The number parameter of the link_message is -1 if it comes from the controller script. The key parameter of the link_message is the UUID of the NPC. The string parameter of the link_message (or through channel 68) is of the format: 473 | ``` 474 | ! [uuid] Bob Bob help 475 | ``` 476 | Where: 477 | - [uuid] is the UUID of the user who gave the command 478 | - Bob is the name of the NPC. The name is repeated once again. 479 | - What follows is the rest of the command that the NPC heard (e.g. "help") 480 | 481 | You can easily split the string with llParseString2List. Look into the ..Extension script for an example. 482 | 483 | ## Sending commands from other objects 484 | 485 | You can send commands directly to the NPC controller from any object. The NPC controller listens on channel 68. You have to remember to send the command using llRegionSay region-wide, so that the controller can hear it. 486 | The syntax is the same as the one used in link_message: 487 | ``` 488 | llRegionSay(68, "! 0000-0000-0000-0000 Bob Bob say hello"); 489 | ``` 490 | The UUID can be zero, and the name of the NPC must be repeated twice, as shown above 491 | * ONLY scripts owned by the owner of the controller can send commands this way * 492 | 493 | 494 | ## Setting controller variables from other objects 495 | 496 | Another way to interact with the controller is by setting variables from other objects by sending SETVAR [variable name] [value] from other objects to channel 68. This is the syntax: 497 | ``` 498 | llRegionSay(68, "SETVAR foo 1"); 499 | ``` 500 | (SETVAR must be in capitals. This example will set the variable "foo" to "1"). 501 | 502 | The variables can be used normally in notecards. In this example notecard, the NPC will waits for the variable "foo" to become '1' before starting to dance: 503 | ``` 504 | @start 505 | say Waiting for variable foo to become 1... 506 | waitvar foo 1 507 | say Variable foo is now 1! Let's dance! 508 | anim dance1 509 | wait 10 510 | stop 511 | setvar foo 0 : Reset var foo to 0 before waiting again 512 | jump start 513 | ``` 514 | 515 | ## Technical Notes 516 | 517 | The controller runs a single timer, that updates the states of all the NPCs every 5 seconds. This allows it to be extremely lightweight, as it does not block any script processing, but it may also cause delays when executing commands. 518 | 519 | The controller checks the number of visitors in your region every 2 minutes. If there are no visitors in the region for 2 minutes, it will stop executing commands to avoid creating unnecessary load to the region. 520 | 521 | # Bugs 522 | 523 | The controller was tested with version 0.8.2.1 . There may be multiple issues with other versions. Please add an issue, or get in touch with Satyr Aeon @ hypergrid.org:8002 524 | 525 | # Thanks 526 | Thanks goes to Spax Orion for testing out lots of features and giving feedback 527 | -------------------------------------------------------------------------------- /WaypointHUD.lsl: -------------------------------------------------------------------------------- 1 | /* Waypoint editor HUD. This only forwards the click to the controller. Controller does all the work */ 2 | 3 | 4 | default 5 | { 6 | state_entry() 7 | { 8 | llSetText("WaypointEditor", <0,0,1>, 1.0); 9 | //startListen(); 10 | 11 | } 12 | 13 | 14 | touch_start(integer num) 15 | { 16 | llRegionSay(68, "ShowPegDialog"); 17 | return; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /_0.scr: -------------------------------------------------------------------------------- 1 | say Hi! 2 | say I feel like dancing 3 | anim dance1 4 | wait 10 5 | stop 6 | say I think that's enough. 7 | say I am now going to pretend i m dying ... 8 | anim dead 9 | wait 5 10 | stop 11 | say I 'm not dead yet dont worry ... 12 | say If you want to change this script, edit the notecard _0.scr . If you dont want me to do anything here, remove the notecard. 13 | say Goodbye now ... 14 | -------------------------------------------------------------------------------- /__config: -------------------------------------------------------------------------------- 1 | AutoLoadOnReset=0 2 | -------------------------------------------------------------------------------- /__initcommands: -------------------------------------------------------------------------------- 1 | Bob say hi 2 | Alice say hi 3 | Bob leave 4 | Alice leave 5 | -------------------------------------------------------------------------------- /__npc_names: -------------------------------------------------------------------------------- 1 | Bob Boticious 2 | Alice Robotilicious 3 | -------------------------------------------------------------------------------- /__permissions: -------------------------------------------------------------------------------- 1 | # The keywords DENY, ALLOW, ALLOWSAMEGROUP etc must be in CAPITALS, and there must be spaces around the ' = ' 2 | # The owner of the controller will always be able to access any command 3 | 4 | Bob say = DENY Evil User # Block the evil user from using the "say" command on Bob 5 | 6 | * say = DENY Evil User # Block the evil user from using the say command on any NPC 7 | 8 | Bob * = DENY Evil User # Block the user from using the any command on Bob 9 | 10 | Bob * = DENYID d37a3f5b-562a-4bfd-b780-68c0b9b940be # Block the user by uuid 11 | 12 | Bob say = DENY * # Disallow anyone to use the "say" command with Bob 13 | 14 | * * = DENY * # Disallow anyone from using any commands on any NNPC 15 | 16 | * * = ALLOWSAMEGROUP # But allow anyone who is in the same group as the controller object to use any command on any NPC 17 | 18 | * * = ALLOW Good User1 # Also allow good user to access any command 19 | 20 | Bob * = ALLOW Goodish User # also allow goodish user to use any commands with bob only 21 | 22 | * dance = ALLOW * # Allow anyone to issue the dance command with any npc 23 | 24 | alice follow = ALLOW * # Allow anyone to use the follow command with alice 25 | 26 | * exec = DENY * 27 | 28 | * loadnpc = DENY * 29 | 30 | * removenpc = DENY * 31 | --------------------------------------------------------------------------------