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 Populate_a_region_with_random_NPC  

Populate_a_region_with_random_NPC

//http://opensimulator.org/wiki/User:Fritigern/Scripts#NPC_stuff
touch to create an NPC at a random position in your region.
The NPC will be created at 100m up in the air, just for dramatic effect :-)
Set npcNum to how many NPCs you want.

License: http://creativecommons.org/licenses/by-sa/2.5/
You are free:
to Share — to copy, distribute and transmit the work
to Remix — to adapt the work
to make commercial use of the work

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

the Zip file

Download all files for Populate_a_region_with_random_NPC
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Populate_a_region_with_random_NPC_1.lsl
1 key npc;
2 vector toucherPos;
3 integer n;
4 integer i;
5 integer npcNum = 5;
6 integer wait = 0;
7 string toucher;
8 key toucherkey;
9
10 default
11 {
13 {
14 llSetText("Populate this region",<1,1,1>,1);
15 }
16
17 touch_start(integer number)
18 {
19 toucher = llKey2Name(llDetectedKey(0));
20 toucherkey = llDetectedKey(0);
21 state raise;
22 }
23 }
24
25 state raise
26 {
28 {
29 for (n=0;n<npcNum;++n)
30 {
31 llSetText("Creating NPC #"+(string)(n+1)+"...",<1,1,1>,1);
32 vector npcPos = <llFrand(255),llFrand(255),100>;
33 osNpcCreate(toucher, "", npcPos, toucherkey);
34
35 if(wait)
36 {
37 for (i=wait;i>0;--i)
38 {
39 llSetText("Creating NPC #"+(string)(n+2)+" in "+(string)i+"...",<1,1,1>,1);
40 llSleep(1);
41 }
42 }
43 }
44 llSetText("Done",<1,1,1>,1);
45 }
46
47 touch_start(integer number)
48 {
49 llSay(0,"Removing all NPCs from this scene!");
50 list avies = osGetAvatarList();
51 for(n=0;n<llGetListLength(avies);n=n+3)
52 {
53 llOwnerSay("Attempting to remove "+llList2String(avies,n+2)+" with UUID "+llList2String(avies,n+0));
54 osNpcRemove((key)llList2Key(avies,n));
55 }
56
58 }
59 }

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