Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
OpenSim NPC NPC_Automator_2  

NPC_Automator_2

From http://opensimulator.org/wiki/NPC_A...

Category: OpenSim NPC
By : Paintball Magic
Created: 2013-07-30 Edited: 2013-07-30
Worlds: OpenSim

the Zip file

Download all files for NPC_Automator_2
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. NPC_Automator_2_1.lsl
1
2 debug(string str)
3 {
4 if(debugger)
5 {
6 llOwnerSay(str);
7 }
8 }
9
10
11 list tempdata;
12 vector offset = <0,0,0>;
13 integer rezcount= 0;
14 integer debugger= FALSE;
15 integer rand= FALSE;
16 key npc = NULL_KEY;
17 string npcfirstname ;
18 string npclastname;
19 vector npcrezpos = <202,119,25>;
20 string detectname = "NPC Name";
21 integer channel = 77;
22 integer line;
23 float delay = 1;
24 string config = "-NPC AI";
25 key readLineId;
26 string NpcCommand;
27 string NpcValue;
28 string command;
29 string value ="value";
30 string extra="extra";
31 string aq;
32 list greet;
33 list aqaintance;
34 string hiufirst="Hello, ";
35 string hiulast=". Nice to meet you!";
36 string hikfirst="Good to see you again, ";
37 string hiklast=".";
38 list triggers;
39 list goto;
40 list gotoqueue;
41 list labels;
42 list labelpos;
43
44 ResetScript()
45 {
47 tempdata =[];
48 npcfirstname = "";
49 npclastname = "";
50 rezcount=0;
51 npc = "";
52 line = 0;
53 triggers=[];
54 goto=[];
55 gotoqueue=[];
56 greet=[];
57 labels=[];
58 labelpos=[];
59 init();
60 state default;
61 }
62
63
64 integer get_aqaintance(string name)
65 {
66 if(llListFindList(aqaintance,[name])<0){return 0;}
67 else{return 1;}
68 }
69
70 set_aqaintance(string name)
71 {
72 string aq=osGetNotecard("Aqaintances");
73 aq+=","+name;
74 aqaintance=llCSV2List(aq);
75 llRemoveInventory("Aqaintances");
76 osMakeNotecard("Aqaintances",[aq]);
77 }
78
79 init_labels()
80 {
81 debug("Starting label initialization");
82 integer i=0;
83 string templine;
84 while(templine != EOF) {
85 templine=osGetNotecardLine(config,i);
86 debug("Reading line: " + templine);
87 list templist = llParseString2List(templine,["|"],[]);
88 string tempcommand = llToLower(llList2String(templist,0));
89 string tempvalue = llList2String(templist,1);
90 if(tempcommand=="label")
91 {
92 labels=labels + [(string)tempvalue];
93 labelpos=labelpos + [(integer)i];
94 debug("Added label " + tempvalue + " to labels.");
95 }
96 i++;
97 }
98 }
99
100 integer label2line(string lblname)
101 {
102 integer tmppos=llListFindList(labels, llToLower(lblname));
103 if(tmppos<0)
104 {
105 debug("label " + lblname + "not found, return to line 0");
106 return 0;
107 }
108 else{
109 return llList2Integer(labelpos, tmppos);
110 }
111 }
112
113 integer IsInteger(string var)
114 {
115 integer i;
116 for (i=0;i<llStringLength(var);++i)
117 {
118 if(!~llListFindList(["1","2","3","4","5","6","7","8","9","0"],[llGetSubString(var,i,i)]))
119 {
120 return FALSE;
121 }
122 }
123 return TRUE;
124 }
125
126 init()
127 {
128 init_labels();
129 //read aquaintances notecard
130 aq=osGetNotecard("Aqaintances");
131 aqaintance=llCSV2List(aq);
132 llSensorRepeat("",NULL_KEY,AGENT,30.0,PI,15);
133
134
135 // reset configuration values to default
136 NpcCommand = "Unknown";
137 NpcValue = "None";
138
139 // make sure the file exists and is a notecard
141 {
142 // notify owner of missing file
143 debug("Missing inventory notecard: " + config);
144 return; // don't do anything else
145 }
146
147 // initialize to start reading from first line
148 line = 0;
149
150 // read the first line
151 readLineId = llGetNotecardLine(config, line++);
152
153 }
154 processConfiguration(string data)
155 {
156 // if we are at the end of the file
157 if(data == EOF)
158 {
159 // notify the owner
160 debug("We are done reading the configuration");
161 // reset
162 line=0;
163 }
164
165 // if we are not working with a blank line
166 if(data != "")
167 {
168 // if the line does not begin with a comment
169 if(llSubStringIndex(data, "#") != 0)
170 {
171 // find first pipe "|" and smoke it
172 integer i = llSubStringIndex(data, "|");
173
174 // if line contains equal sign
175 if(i != -1)
176 {
177 tempdata = llParseString2List(data,["|"],[]);
178 command = llToLower(llList2String(tempdata,0));
179 value = llList2String(tempdata,1);
180 extra = llDumpList2String(llList2List(tempdata,2,-1)," ");
181
182 debug( " Command " +command + " Value " + value + " Extra " +extra);
183 if(command == "npccreate" && value !="" )
184 {
185 //NpcCommand = value;
186 list tempname = llParseString2List(value,[" "],[]);
187 string fname = llList2String(tempname,0);
188 string lname = llList2String(tempname,1);
189 npcfirstname = (string)fname;
190 npclastname = (string)lname;
191 offset = (vector)extra;
192 if(CardExists(npcfirstname + "_" + npclastname))
193 {
194 debug("A saved appearance for " + npcfirstname + " " + npclastname + " was found.");
195 npc = osNpcCreate(npcfirstname, npclastname, llGetPos()+offset, npcfirstname + "_" + npclastname);
196 lognpc(npc);
197 debug("Created NPC " + (string)npc + " with the name " + npcfirstname + " " + npclastname + ".");
198
199 }
200 else{
201 debug("No appearance for " + npcfirstname + " " + npclastname + " found. Copying your appearance.");
202 osOwnerSaveAppearance(npcfirstname + "_" + npclastname);
203 npc = osNpcCreate(npcfirstname, npclastname, llGetPos()+offset, npcfirstname + "_" + npclastname);
204 lognpc(npc);
205 debug("Created NPC " + (string)npc + " with the name " + npcfirstname + " " + npclastname + "." +(string)npcrezpos);
206 debug( "Created " + npcfirstname + "_" + npclastname + " @ " +extra);
207 // color
208 }
209 }
210 else if(command == "wait")
211 {
212 llSetTimerEvent((float)value);
213 debug( "wait " + value);
214 }
215 else if(command == "gotoline")
216 {
217 if(IsInteger(value))
218 {
219 line = (integer)value;
220 }
221 else{
222 line = label2line(value);
223 }
224 debug( "go to line " + value);
225 }
226 else if(command == "npcflyto")
227 {
228 osNpcMoveToTarget(npc, (vector)value, OS_NPC_FLY);
229 debug( "move to " + value);
230 }
231 else if(command == "npcmoveto")
232 {
233 osNpcMoveToTarget(npc, (vector)value, OS_NPC_NO_FLY);
234 debug( "move to " + value + " " +extra);
235 }
236 else if(command == "npcsetrot")
237 {
238 if(value == llToLower("set"))
239 {
240 rand = FALSE;
241 debug( "No Rotaion Timer");
242 }
243 else if(value == llToLower("random"))
244 {
245 rand = TRUE;
246 debug( "Random rotation set every timer");
247 }
248 }
249 else if(command == "npcplayanimation")
250 {
251 osNpcPlayAnimation(npc, value);
252 debug( "animate " + value);
253 }
254 else if(command == "npcstopanimation")
255 {
256 osNpcStopAnimation(npc, value);
257 debug( "stop animate " + value);
258 }
259 else if(command == "npcsay")
260 {
261 osNpcSay(npc, value);
262 //debug( "stop animate " + value);
263 }
264 else if(command == "wait")
265 {
266 delay = (float)value;
267 debug( " setimer " + value);
268 }
269 else if(command == "npcsit")
270 {
271 osNpcSit(npc,(key)value,1);
272 }
273 else if(command == "npcdelete")
274 {
275 NpcDelete();
276 }
277 else if(command == "greetstrangerfirst")
278 {
279 hiufirst=value;
280 }
281 else if(command == "greetstrangerlast")
282 {
283 hiulast=value;
284 }
285 else if(command == "greetaquaintancefirst")
286 {
287 hikfirst=value;
288 }
289 else if(command == "greetaquaintancelast")
290 {
291 hiklast=value;
292 }
293 else if(command == "addtrigger")
294 {
295 integer tmpline;
296 triggers=triggers + [llToLower(value)];
297 if(IsInteger(extra))
298 {
299 tmpline = (integer)extra;
300 }
301 else{
302 tmpline = label2line(extra);
303 }
304 goto=goto + [(integer)tmpline];
305 debug("Added trigger \"" + value + " with goto value of " + extra + ".");
306 }
307 else if(command == "removetrigger")
308 {
309 integer pos=llListFindList(triggers,llToLower(value));
310 if(pos<0){debug("Trigger not found");}
311 else{
312 triggers=llDeleteSubList(triggers,pos,pos);
313 goto=llDeleteSubList(goto,pos,pos);
314 debug("Deleted trigger with value \"" + value);
315 }
316 }
317 else if(command == "gototrigger")
318 {
319 integer length=llGetListLength(gotoqueue);
320 if(length>0)
321 {
322 integer goto=llList2Integer(gotoqueue, 0);
323 line = goto;
324 gotoqueue=llDeleteSubList(gotoqueue,0,0);
325 debug( "loops back to line " + goto);
326 }
327 }
328 else if(command == "label")
329 {
330 debug("Now at label " + value);
331 }
332 // unknown name osNpcSit(npc,"bca94960-4fd9-4512-85e1-fd7faf130aba",1);
333 else{
334 //debug("Unknown configuration value: " + name + " on line " + (string)line);
335 }
336 }
337 else // line does not contain equal sign
338 {
339 debug("Configuration could not be read on line " + (string)line);
340 }
341 }
342 }
343 // read the next line
344 // readLineId = llGetNotecardLine(config, line++);
345 }
346
347 // Enter multiple NPCs into a list just incase of name change, Send linked message to other script(s) if needed
348 lognpc(key npcl)
349 {
350 llSetObjectDesc(npc);
351 dead = FALSE;
352 integer i;
353 for (i=0;i<rezcount;i++)
354 {
355 npc = osNpcCreate(npcfirstname, npclastname + " " + (string)i, llGetPos()+offset, npcfirstname + "_" + npclastname);
356 llMessageLinked(LINK_THIS,-5,"npcid",npc);
357 }
358 }
359
360 integer CardExists(string cardname)
361 {
363 {
364 return FALSE;
365 }
366 else{
367 return TRUE;
368 }
369 }
370
371 NpcCreate(list cmdline, integer cmdlength)
372 {
373 // Create a new NPC. Use an existing appearance if a
374 // notecard matching the given name exists, otherwise
375 // use the creator's appearance.
376 if(npc != NULL_KEY)
377 {
378 debug(llGetObjectName() + " thinks you still have an active NPC. Either delete that NPC, use the clearid command, or reset the scripts in " + llGetObjectName() + ".");
379 return;
380 }
381 if(cmdlength != 3)
382 {
383 debug("Command usage: create <firstname> <lastName>");
384 return;
385 }
386 npcfirstname = llList2String(cmdline, 1);
387 npclastname = llList2String(cmdline, 2);
388 if(CardExists(npcfirstname + "_" + npclastname))
389 {
390 debug("A saved appearance for " + npcfirstname + " " + npclastname + " was found.");
391 npc = osNpcCreate(npcfirstname, npclastname, llGetPos()+offset, npcfirstname + "_" + npclastname);
392 lognpc(npc);
393 debug("Created NPC " + (string)npc + " with the name " + npcfirstname + " " + npclastname + ".");
394 }
395 else{
396 debug("No appearance for " + npcfirstname + " " + npclastname + " found. Copying your appearance.");
397 osOwnerSaveAppearance(npcfirstname + "_" + npclastname);
398 npc = osNpcCreate(npcfirstname, npclastname, llGetPos()+offset, npcfirstname + "_" + npclastname);
399 lognpc(npc);
400 debug("Created NPC " + (string)npc + " with the name " + npcfirstname + " " + npclastname + ".");
401 return;
402 }
403 }
404
405 NpcSave(list cmdline, integer cmdlength)
406 {
407 // Save the NPC's current appearance to a notecare. Accepts a
408 // notecard name as an optional parameter. Card name will be
409 // the NPC's name if not specified, i.e.: John_Smith
410
411 if(npc == NULL_KEY)
412 {
413 debug("Can't save appearance because no NPC has been created. Create an NPC, or use setid to specify a rezzed NPC.");
414 return;
415 }
416 if(cmdlength = 1)
417 {
418 osNpcSaveAppearance(npc, npcfirstname + "_" + npclastname);
419 debug("NPC appearance saved as: " + npcfirstname + "_" + npclastname);
420 return;
421 }
422 else if(cmdlength = 2)
423 {
424 osNpcSaveAppearance(npc, llList2String(cmdline, 1));
425 debug("NPC appearance saved as: " + llList2String(cmdline, 1));
426 return;
427 }
428 else{
429 debug("Command usage: save [<cardname>]");
430 return;
431 }
432 }
433
434 NpcLoad(list cmdline, integer cmdlength)
435 {
436 // Load an appearance from a notecard, and apply it to the NPC.
437 if(npc == NULL_KEY)
438 {
439 debug("Cannot load an appearance because there is no NPC. Either create one, or assign the UUID of an existing NPC with setid.");
440 return;
441 }
442 if(cmdlength == 1)
443 {
444 // No appearance was specified, so use the notecard created when the
445 // NPC was created.
446 if(CardExists("Test_NPC"))
447 {
448 osNpcLoadAppearance(npc, "Test_NPC");
449 debug("Default appearance loaded.");
450 return;
451 }
452 else{
453 debug("Cannot load an appearance. No NPC may have been created yet.");
454 return;
455 }
456 return;
457 }
458 else if(cmdlength == 2)
459 {
460 // Attempt to load an appearance notecard from a specified notecard.
461 string cardname = llList2String(cmdline, 1);
462 if(CardExists(cardname))
463 {
464 osNpcLoadAppearance(npc, cardname);
465 debug("NPC appearance loaded from the notecard " + cardname + ".");
466 return;
467 }
468 else{
469 debug("The notecard " + cardname + " was not found.");
470 return;
471 }
472 return;
473 }
474 else if(cmdlength == 3)
475 {
476 // Attempt to load an appearance notcard associated with provided NPC name.
477 string cardname = llList2String(cmdline, 1) + "_" + llList2String(cmdline, 2);
478 if(CardExists(cardname))
479 {
480 osNpcLoadAppearance(npc, cardname);
481 debug("Loaded the stored appearance for " + llList2String(cmdline,1) + " " + llList2String(cmdline, 2) + ".");
482 return;
483 }
484 else{
485 debug("Cannot load the requested appearance. No notecard associated with " + llList2String(cmdline, 1) + " " + llList2String(cmdline, 2) + " was found.");
486 return;
487 }
488 return;
489 }
490 else{
491 debug("Command usage: load [<cardname> | <firstname> <lastname>]");
492 }
493 }
494
495 NpcDelete()
496 {
497 // Derez the NPC and clear associated info.
498 if(npc == NULL_KEY)
499 {
500 debug("Can't delete because no NPC has been created. Create an NPC, or use setid to specify a rezzed NPC.");
501 return;
502 }
503 string name = llKey2Name(npc);
504 osNpcRemove(npc);
505 npc = NULL_KEY;
506 dead = TRUE;
508 // npcfirstname = "";
509 //npclastname = "";
510 debug("Deleted the NPC named " + name + ".");
511 }
512
513 NpcCopy()
514 {
515 // Copy the appearance of the user to the NPC, and save it to a default
516 // notecard named Test_NPC.
517 if(npc == NULL_KEY)
518 {
519 debug("Cannot copy your appearance to the NPC because no NPC exists. Either create one, or assign the UUID of an existing NPC with setid.");
520 return;
521 }
522 osOwnerSaveAppearance("Test_NPC");
523 osNpcLoadAppearance(npc, "Test_NPC");
524 debug("Your appearance has been saved to the NPC.");
525 return;
526 }
527
528 NpcSetUUID(list cmdline, integer cmdlength)
529 {
530 // Assign currently active agent UUID.
531 if(cmdlength < 2 || cmdlength > 3)
532 {
533 debug("Command usage: setid <UUID>");
534 debug("Command usage: setid <firstname> <lastname>");
535 return;
536 }
537 key newUUID = llList2Key(cmdline, 1);
538 string name = llKey2Name(newUUID);
539 if(cmdlength == 2)
540 {
541 if(name != "")
542 {
543 // Set the active NPC UUID to the one provided.
544 debug npclastname = llList2String(namelist, 1);
545 debug("The NPC's UUID is now " + npc + ".");
546 return;
547 }
548 else{
549 debug("No existing NPC was found for this UUID.");
550 return;
551 }
552 }
553 if(cmdlength = 3)
554 {
555 // Attempt to detect and assign the NPC UUID by detecting it from
556 // a provided agent name.
557 detectname = llList2String(cmdline, 1) + " " + llList2String(cmdline, 2);
558 state DetectAgent;
559 }
560 }
561
562 CommandExec(list cmdline)
563 {
564 // Commands are interpreted and executed in this function.
565 string cmd = llToLower(llList2String(cmdline, 0));
566 integer cmdlength = llGetListLength(cmdline);
567 if(cmd == "create")
568 {
569 rezcount=0;
570 NpcCreate(cmdline, cmdlength);
571 return;
572 }
573 else if(cmd == "setupnpc")
574 {
575 npc = osNpcCreate(npcfirstname, npclastname, llGetPos() + <0, 1, 0>, "Test_NPC");
576 lognpc(npc);
577 return;
578 }
579 else if(cmd == "save")
580 {
581 NpcSave(cmdline, cmdlength);
582 return;
583 }
584 else if(cmd == "load")
585 {
586 NpcLoad(cmdline, cmdlength);
587 return;
588 }
589 else if(cmd == "delete")
590 {
591 NpcDelete();
592 return;
593 }
594 else if(cmd == "copy")
595 {
596 NpcCopy();
597 return;
598 }
599 else if(cmd == "setid")
600 {
601 NpcSetUUID(cmdline, cmdlength);
602 return;
603 }
604 else if(cmd == "getid")
605 {
606 debug("Current NPC is " + npcfirstname + " " + npclastname + ", with the UUID " + (string)npc);
607 return;
608 }
609 else if(cmd == "clearid")
610 {
611 npc = NULL_KEY;
613 debug("NPC UUID has been set to NULL_KEY.");
614 return;
615 }
616 else if(cmd == "help")
617 {
618 CommandHelp(cmdline);
619 return;
620 }
621 else if(cmd == "test")
622 {
623 string s = llKey2Name(npc);
624 debug(s);
625 }
626 else{
627 debug("Unknown command: " + llDumpList2String(cmdline, " "));
628 debug("Use the help command for a list of commands.");
629 }
630 }
631
632 CommandHelp(list cmdline)
633 {
634 // This function provides command instructions and usage information.
635 string cmd = llList2String(cmdline, 0);
636 integer cmdlength = llGetListLength(cmdline);
637 if(cmdlength == 1)
638 {
639 debug("The following commands are available:");
640 debug("\thelp \tcreate \tsave \tload \tdelete");
641 debug("\tcopy \tsetid \tgetid \tclearid");
642 debug("Use \"help <command>\" to get more information on an item in the list.");
643 return;
644 }
645 else if(cmdlength == 2)
646 {
647 string param = llList2String(cmdline, 1);
648 if(param == "save")
649 {
650 debug("The save command saves the current appearance of the NPC to a notecard. If no notecard name is specified, the name is set to the first and last names of the NPC, seperated by an underscore.");
651 debug("Command usage: save [<cardname>]");
652 debug("Example: save John_Smith");
653 return;
654 }
655 if(param == "load")
656 {
657 debug("The load command saves the current appearance of the NPC to a notecard. When not given an parameters, it attempts to load the card created when the NPC was created. It will also attempt to load any notecard when a name is spefified. Finally, it will try to load a notecard named after an NPC.");
658 debug("Command usage: load [<cardname> | <firstname> <lastname>]");
659 debug("Example: load");
660 debug("Example: load mynotecard");
661 debug("Example: load John Smith");
662 return;
663 }
664 else if(param == "delete")
665 {
666 debug("The delete command removes the current NPC from the scene.");
667 debug("Command usage: delete");
668 return;
669 }
670 else if(param == "create")
671 {
672 debug("The create command creates a new NPC. If it does not find a previously stored appearance for the given NPC name, it copies the appearance of its creator. All subsequent commands will be applied to this new NPC.");
673 debug("Command usage: create <firstname> <lastName>");
674 debug("Example: create John Smith");
675 return;
676 }
677 else if(param == "copy")
678 {
679 debug("The copy command makes a copy of the user's appearance, and applies it to the NPC.");
680 debug("Command usage: copy");
681 return;
682 }
683 else if(param == "setid")
684 {
685 debug("The setid command tells " + llGetObjectName() + " which NPC it is working with. Can be provided with an explicit UUID, or given a first and last name from which it will attempt to detect the UUID.");
686 debug("Command usage: setid <UUID>");
687 debug("Command usage: setid <firstname> <lastname>");
688 debug("Example: setid e254e947-65d0-4bc8-b70a-6e6c05bf0535");
689 return;
690 }
691 else if(param == "getid")
692 {
693 debug("The getid command retrieves and displays the UUID for the current active NPC.");
694 debug("Command usage: getid");
695 return;
696 }
697 else if(param == "clearid")
698 {
699 debug("The clearid command sets the NPC's UUID to NULL_KEY.");
700 debug("Command usage: clearid");
701 return;
702 }
703 else if(param == "help")
704 {
705 debug("Please see the help command.");
706 debug("Command usage: help");
707 return;
708 }
709 }
710 else{
711 debug("Command usage: help [<command>]");
712 return;
713 }
714 }
715
716 integer anim = FALSE;
717 integer dead = TRUE;
718
719 default
720 {
721 on_rez(integer start_param)
722 {
723 ResetScript();
724 }
725 changed(integer change)
726 {
727 if(change & CHANGED_INVENTORY)
728 {
729 NpcDelete();
730 llSleep(3);
731 ResetScript();
732 }
733 else if(change & CHANGED_OWNER)
734 {
735 ResetScript();
736 }
737 }
739 {
740 llListen(channel, "", NULL_KEY, "");
741 llListen(0,"",NULL_KEY,"");
742 init();
744 //llSensor("", NULL_KEY, AGENT, 4.0, PI);
745 debug(llGetObjectName() + " started on channel " + (string)channel + ".");
746 debug("Use the help command to get started.");
747 debug("Example: /" + (string)channel + " help");
748 anim = FALSE;
750 debug("RUNNING");
751 }
752 timer()
753 {
754 if((llKey2Name(npc) == "" && (dead != TRUE)))
755 {
756 ResetScript();
757 }
758 else{
759 // osNpcPlayAnimation(npc, "Hello";
760 if(rand)
761 {
762 osNpcSetRot(npc, llGetRot() * (llEuler2Rot(<0, 0, llFrand(360)> * DEG_TO_RAD))); // Setting Random Rotation every wait
763 }
764 readLineId = llGetNotecardLine(config, line++);
765 }
766 llSetTimerEvent(delay);
767 }
768 dataserver(key request_id, string data)
769 {
770 if(request_id == readLineId)
771 {
772 processConfiguration(data);
773 }
774 }
775
776 listen(integer chan, string name, key id, string msg)
777 {
778 if(chan==channel)
779 {
780 if(msg == "" ) { return; }
781 if(id != llGetOwner())
782 {
783 // llSay(0, "Only the owner of " + llGetObjectName() + " may issue commands.";
784 }
785 list commandline = llParseString2List(msg, [" "], []);
786 CommandExec(commandline);
787 }
788 if(chan==0)
789 {
790 //conversations
791 if(id!=npc)
792 {
793 integer length = llGetListLength(triggers);
794 integer i;
795 for (i = 0; i < length; ++i) {
796 string word = llList2String(triggers, i);
797 integer found=llSubStringIndex(llToLower(msg),word);
798 if(found>-1)
799 {
800 integer address=llList2Integer(goto,i);
801 gotoqueue= [(integer)address] + gotoqueue;
802 debug("Added address " + address + " to gotoqueue.");
803 }
804 }
805 }
806 }
807 }
808
809 sensor(integer num)
810 {
811 integer count=0;
812 while(count<num)
813 {
814 string myname=npcfirstname + " " + npclastname;
815 string name=llKey2Name(llDetectedKey(count));
816 if(name!=myname)
817 {
818 if(llListFindList(greet,[name])<0)
819 {
820 greet+=[name];
821 integer space=llSubStringIndex(name," ");
822 string firstName=llGetSubString(name,0,space-1);
823 integer known=get_aqaintance(name);
824 llSleep(0.5);
825 if(known==0){
826 osNpcSay(npc,hiufirst + firstName + hiulast);
827 set_aqaintance(name);
828 }
829 else{
830 osNpcSay(npc,hikfirst + firstName + hiklast);
831 }
832 }
833 }
834 count++;
835 }
836 }
837 no_sensor()
838 {
839 greet=[];
840 }
841 }
842
843 state DetectAgent
844 {
846 {
847 llSensor(detectname, NULL_KEY, AGENT, 96, PI);
848 }
849 sensor(integer number)
850 {
851 debug("The entity named " + detectname + " was found.");
852 npc = llDetectedKey(0);
854 list namelist = llParseString2List(detectname, [" "], []);
855 npcfirstname = llList2String(namelist, 0);
856 npclastname = llList2String(namelist, 1);
857 debug("The NPC's UUID is now " + npc + ".");
858 detectname = "";
859 state default;
860 }
861 no_sensor()
862 {
863 debug("The entity named " + detectname + " was not found.");
864 detectname = "";
865 gotoqueue=[];
866 state default;
867 }
868 }

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