OsNpcCreate

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
Line 8: Line 8:
 
ossl_example = <source lang="lsl">
 
ossl_example = <source lang="lsl">
 
// touch to create npc in front of this emitter
 
// touch to create npc in front of this emitter
 +
// Npc will walk to the toucher, then will greet them.
 
// touch again to destroy
 
// touch again to destroy
  
 
key npc;
 
key npc;
 +
vector toucherPos;
  
 
default
 
default
Line 18: Line 20:
 
         vector npcPos = llGetPos() + <1,0,0>;
 
         vector npcPos = llGetPos() + <1,0,0>;
 
         npc = osNpcCreate("Jane", "Bot", npcPos, llGetOwnerKey(llGetKey()));
 
         npc = osNpcCreate("Jane", "Bot", npcPos, llGetOwnerKey(llGetKey()));
 +
        list rtn = llGetObjectDetails(llDetectedKey(number), [OBJECT_POS]);
 +
        toucherPos = llList2Vector(rtn, 0);
 
         state hasNPC;
 
         state hasNPC;
 
     }
 
     }
Line 24: Line 28:
 
state hasNPC
 
state hasNPC
 
{
 
{
 +
    state_entry()
 +
    {
 +
        osNpcMoveTo(npc, toucherPos + <1,0,0>); // This is currently unworkable
 +
        osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc));
 +
    }
 +
 
     touch_start(integer number)
 
     touch_start(integer number)
 
     {
 
     {
 +
        osNpcSay(npc, "Good bye!");
 
         osNpcRemove(npc);
 
         osNpcRemove(npc);
 
         npc = NULL_KEY;
 
         npc = NULL_KEY;
Line 33: Line 44:
 
</source>
 
</source>
 
|  
 
|  
additional_info = *This function creates a NPC(Non Player Character) clone from an already existing avatar UUID Key.
+
additional_info = *Creates a NPC(Non Player Character) clone named '''firstname''' '''lastname''' at '''position''' from an already existing avatar '''cloneFrom'''.
 
*Note: This function may not work as you have intended. See [http://opensimulator.org/mantis/view.php?id=5148 Mantis #5148] for more information.
 
*Note: This function may not work as you have intended. See [http://opensimulator.org/mantis/view.php?id=5148 Mantis #5148] for more information.
 
|
 
|
 
}}
 
}}

Revision as of 04:59, 30 June 2011

key osNpcCreate(string firstname, string lastname, vector position, key cloneFrom);
No descriptions provided
Threat Level High
Permissions No permissions specified
Delay No function delay specified
Example(s)
// touch to create npc in front of this emitter
// Npc will walk to the toucher, then will greet them.
// touch again to destroy
 
key npc;
vector toucherPos;
 
default
{
    touch_start(integer number)
    {
        vector npcPos = llGetPos() + <1,0,0>;
        npc = osNpcCreate("Jane", "Bot", npcPos, llGetOwnerKey(llGetKey()));
        list rtn = llGetObjectDetails(llDetectedKey(number), [OBJECT_POS]);
        toucherPos = llList2Vector(rtn, 0);
        state hasNPC;
    }
}
 
state hasNPC
{
    state_entry()
    {
        osNpcMoveTo(npc, toucherPos + <1,0,0>); // This is currently unworkable
        osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc));
    }
 
    touch_start(integer number)
    {
        osNpcSay(npc, "Good bye!");
        osNpcRemove(npc);
        npc = NULL_KEY;
        state default;
    }
}
Notes
*Creates a NPC(Non Player Character) clone named firstname lastname at position from an already existing avatar cloneFrom.
  • Note: This function may not work as you have intended. See Mantis #5148 for more information.
Personal tools
General
About This Wiki