User:Fritigern/Scripts

From OpenSimulator

< User:Fritigern
Revision as of 20:26, 8 August 2011 by Fritigern (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Playing around with NPCs. Here are some scripts that i use to play with them. I constantly change the scripts around, so what you see here, is not necessarily what i currently have in-world.

These scripts can be really dirty, with hacks, and code commented out, and most likely weird, inefficient, or otherwise questionable ways of doing things. Such is the result of constant fooling around and changing stuffs ;-)

Populate Region

// 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 :-)
 
key npc;
vector toucherPos;
integer n;
integer i;
integer npcNum = 5;
integer wait = 0;
string toucher;
key toucherkey;
 
default
{
    state_entry()
    {
        llSetText("Populate this region",<1,1,1>,1);
    }
 
    touch_start(integer number)
    {
        toucher = llKey2Name(llDetectedKey(0));
        toucherkey = llDetectedKey(0);
        state raise;
    }
}
 
state raise
{
    state_entry()
    {
        for (n=0;n<=npcNum;++n)
        {
            llSetText("Creating NPC #"+(string)(n+1)+"...",<1,1,1>,1);
            vector npcPos = <llFrand(255),llFrand(255),100>;
            osNpcCreate(toucher, "", npcPos, toucherkey);
 
            if (wait)
            {
                for (i=wait;i>0;--i)
                {
                    llSetText("Creating NPC #"+(string)(n+2)+" in "+(string)i+"...",<1,1,1>,1);
                    llSleep(1);                
                }
            }
        }
        llSetText("Done",<1,1,1>,1);
    }
 
    touch_start(integer number)
    {
        llSay(0,"Removing all NPCs from this scene!");
        list avies = osGetAvatarList();
        for(n=0;n<llGetListLength(avies);n=n+3)
        {
            llOwnerSay("Attempting to remove "+llList2String(avies,n+2)+" with UUID "+llList2String(avies,n+0));
            osNpcRemove((key)llList2Key(avies,n));
        }
 
        llResetScript();
    }
}
Personal tools
General
About This Wiki