OsNpcCreate

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Changed example to save avatyar appearabnce in notecard first)
Line 1: Line 1:
 
{{osslfunc
 
{{osslfunc
 
|threat_level=High
 
|threat_level=High
|function_syntax=key osNpcCreate(string firstname, string lastname, vector position, key cloneFrom)
+
|function_syntax=key osNpcCreate(string firstname, string lastname, vector position, string notecard)
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
// touch to create npc in front of this emitter
+
// touch to create a NPC clone of the toucher in front of this emitter
// Npc will walk to the toucher, then will greet them.
+
// NPC will move to the toucher, then will greet them.
 
// Touch again to remove the NPC
 
// Touch again to remove the NPC
  
Line 15: Line 15:
 
     {
 
     {
 
         vector npcPos = llGetPos() + <1,0,0>;
 
         vector npcPos = llGetPos() + <1,0,0>;
         npc = osNpcCreate("ImYour", "Clone", npcPos, llGetOwnerKey(llGetKey()));
+
        osAgentSaveAppearance(llDetectedKey(0), "appearance");
 +
         npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
 
         toucherPos = llDetectedPos(0);
 
         toucherPos = llDetectedPos(0);
 
         state hasNPC;
 
         state hasNPC;
Line 25: Line 26:
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         osNpcMoveTo(npc, toucherPos + <1,0,0>); // osNpcMoveTo will currently not work as intended.
+
         osNpcMoveTo(npc, toucherPos + <3,0,0>);  
 
         osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc));
 
         osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc));
 
     }
 
     }
Line 39: Line 40:
 
</source>
 
</source>
 
|description=*Creates a NPC(Non Player Character) clone named '''firstname''' '''lastname''' at '''position''' from an already existing avatar  '''cloneFrom'''.
 
|description=*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.
 
<!-- It broke again. Uncommenting when it works again.
 
*Note: Since revision [http://opensimulator.org/viewgit/?a=commit&p=opensim&h=59f548cda82facef003fb7309180412254a234a1 r/16413], dated Aug 1st, 2011, this function works again, with the caveat that osNpcCreate will only clone avatars currently in the region.
 
-->
 
 
|
 
|
 
}}
 
}}

Revision as of 03:31, 16 August 2011

key osNpcCreate(string firstname, string lastname, vector position, string notecard)
  • Creates a NPC(Non Player Character) clone named firstname lastname at position from an already existing avatar cloneFrom.
Threat Level High
Permissions No permissions specified
Extra Delay No function delay specified
Example(s)
// touch to create a NPC clone of the toucher in front of this emitter
// NPC will move to the toucher, then will greet them.
// Touch again to remove the NPC
 
key npc;
vector toucherPos;
 
default
{
    touch_start(integer number)
    {
        vector npcPos = llGetPos() + <1,0,0>;
        osAgentSaveAppearance(llDetectedKey(0), "appearance");
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
        toucherPos = llDetectedPos(0);
        state hasNPC;
    }
}
 
state hasNPC
{
    state_entry()
    {
        osNpcMoveTo(npc, toucherPos + <3,0,0>); 
        osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc));
    }
 
    touch_start(integer number)
    {
        osNpcSay(npc, "Good bye!");
        osNpcRemove(npc);
        npc = NULL_KEY;
        state default;
    }
}
Personal tools
General
About This Wiki