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
NPC OpenSim NPC Populate Region Randomly  

OpenSim NPC Populate Region Randomly

Touch to create an NPC at a random position in your region.

Category: NPC
By : Fritigern
Created: 2014-02-20 Edited: 2014-02-20
Worlds: OpenSim

the Zip file

Download all files for OpenSim NPC Populate Region Randomly
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1 // :SOURCE: http://opensimulator.org/wiki/User:Fritigern/Scripts
2 // touch to create an NPC at a random position in your region.
3 // The NPC will be created at 100m up in the air, just for dramatic effect :-)
4 // Set npcNum to how many NPCs you want.
5
6 key npc;
7 vector toucherPos;
8 integer n;
9 integer i;
10 integer npcNum = 5;
11 integer wait = 0;
12 string toucher;
13 key toucherkey;
14
15 default
16 {
18 {
19 llSetText("Populate this region",<1,1,1>,1);
20 }
21
22 touch_start(integer number)
23 {
24 toucher = llKey2Name(llDetectedKey(0));
25 toucherkey = llDetectedKey(0);
26 state raise;
27 }
28 }
29
30 state raise
31 {
33 {
34 for (n=0;n<npcNum;++n)
35 {
36 llSetText("Creating NPC #"+(string)(n+1)+"...",<1,1,1>,1);
37 vector npcPos = <llFrand(255),llFrand(255),100>;
38 osNpcCreate(toucher, "", npcPos, toucherkey);
39
40 if(wait)
41 {
42 for (i=wait;i>0;--i)
43 {
44 llSetText("Creating NPC #"+(string)(n+2)+" in "+(string)i+"...",<1,1,1>,1);
45 llSleep(1);
46 }
47 }
48 }
49 llSetText("Done",<1,1,1>,1);
50 }
51
52 touch_start(integer number)
53 {
54 llSay(0,"Removing all NPCs from this scene!");
55 list avies = osGetAvatarList();
56 for(n=0;n<llGetListLength(avies);n=n+3)
57 {
58 llOwnerSay("Attempting to remove "+llList2String(avies,n+2)+" with UUID "+llList2String(avies,n+0));
59 osNpcRemove((key)llList2Key(avies,n));
60 }
61
63 }
64 }

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