OsNpcSaveAppearance

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Add See Also)
(Ooops, it's for the NPCs here not the Agents (scripts replaced))
Line 10: Line 10:
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
 
//
 
//
// osAgentSaveAppearance Script Example
+
// osNpcSaveAppearance Script Exemple
 
// Author: djphil
 
// Author: djphil
 
//
 
//
Line 18: Line 18:
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance usage.");
+
         llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcSaveAppearance usage.");
 
     }
 
     }
 
+
     touch_start(integer number)
+
     collision_start(integer number)
 
     {
 
     {
         key toucher = llDetectedKey(0);
+
         key collider = llDetectedKey(0);
 
+
         if (llGetAgentSize(toucher) != ZERO_VECTOR)
+
         if (osIsNpc(collider))
 
         {
 
         {
             string FullName = llDetectedName(0);
+
             string FullName = osKey2Name(collider);
 
             list buffer = llParseString2List(FullName, " ", []);
 
             list buffer = llParseString2List(FullName, " ", []);
 
             string FirstName = llList2String(buffer, 0);
 
             string FirstName = llList2String(buffer, 0);
 
             string LastName = llList2String(buffer, 1);
 
             string LastName = llList2String(buffer, 1);
 
             string NotecardName = FirstName + " " + LastName + " " + llGetTimestamp();
 
             string NotecardName = FirstName + " " + LastName + " " + llGetTimestamp();
            llSay(PUBLIC_CHANNEL, "Attempting to create an Notecard \"" + NotecardName + "\".");
+
             key result = osNpcSaveAppearance(collider, NotecardName);
 
+
             key result = osAgentSaveAppearance(toucher, NotecardName);
+
  
 
             if (result && result != NULL_KEY)
 
             if (result && result != NULL_KEY)
 
             {
 
             {
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + NotecardName + "\" created with success.");
+
                 osNpcSay(collider, "Notecard \"" + NotecardName + "\" created with success.");
 
             }
 
             }
  
 
             else
 
             else
 
             {
 
             {
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + NotecardName + "\" created without success.");
+
                 osNpcSay(collider, "Notecard \"" + NotecardName + "\" created without success.");
 
             }
 
             }
 
         }
 
         }
Line 49: Line 47:
 
         else
 
         else
 
         {
 
         {
             llInstantMessage(toucher, "You need to be in the same region to use this function ...");
+
             llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and save their appearance in a notecard ...");
 
         }
 
         }
 
     }
 
     }
Line 57: Line 55:
 
<source lang="lsl">
 
<source lang="lsl">
 
//
 
//
// osAgentSaveAppearance (with option) Script Example
+
// osNpcSaveAppearance Script Exemple
 
// Author: djphil
 
// Author: djphil
 
//
 
//
  
 
integer includeHuds = TRUE;
 
integer includeHuds = TRUE;
 
+
 
default
 
default
 
{
 
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance (with option) usage.");
+
         llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcSaveAppearance usage.");
 
     }
 
     }
 
+
     touch_start(integer number)
+
     collision_start(integer number)
 
     {
 
     {
         key toucher = llDetectedKey(0);
+
         key collider = llDetectedKey(0);
 
+
         if (llGetAgentSize(toucher) != ZERO_VECTOR)
+
         if (osIsNpc(collider))
 
         {
 
         {
             string FullName = llDetectedName(0);
+
             string FullName = osKey2Name(collider);
 
             list buffer = llParseString2List(FullName, " ", []);
 
             list buffer = llParseString2List(FullName, " ", []);
 
             string FirstName = llList2String(buffer, 0);
 
             string FirstName = llList2String(buffer, 0);
 
             string LastName = llList2String(buffer, 1);
 
             string LastName = llList2String(buffer, 1);
 
             string NotecardName = FirstName + " " + LastName + " " + llGetTimestamp();
 
             string NotecardName = FirstName + " " + LastName + " " + llGetTimestamp();
            llSay(PUBLIC_CHANNEL, "Attempting to create an Notecard \"" + NotecardName + "\".");
 
  
 
             key result;
 
             key result;
 
+
 
             if (includeHuds == TRUE)
 
             if (includeHuds == TRUE)
 
             {
 
             {
                 result = osAgentSaveAppearance(toucher, NotecardName, TRUE);
+
                 result = osNpcSaveAppearance(collider, NotecardName, TRUE);
 
             }
 
             }
           
+
 
             else
 
             else
 
             {
 
             {
                 result = osAgentSaveAppearance(toucher, NotecardName, FALSE);
+
                 result = osNpcSaveAppearance(collider, NotecardName, FALSE);
 
             }
 
             }
 
+
 
             if (result && result != NULL_KEY)
 
             if (result && result != NULL_KEY)
 
             {
 
             {
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + NotecardName + "\" created with success.");
+
                 osNpcSay(collider, "Notecard \"" + NotecardName + "\" created with success.");
 
             }
 
             }
  
 
             else
 
             else
 
             {
 
             {
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + NotecardName + "\" created without success.");
+
                 osNpcSay(collider, "Notecard \"" + NotecardName + "\" created without success.");
 
             }
 
             }
 
         }
 
         }
Line 108: Line 105:
 
         else
 
         else
 
         {
 
         {
             llInstantMessage(toucher, "You need to be in the same region to use this function ...");
+
             llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and save their appearance in a notecard ...");
 
         }
 
         }
 
     }
 
     }

Revision as of 15:02, 4 December 2020

key osNpcSaveAppearance(key npc, string notecard)

key osNpcSaveAppearance(key npc, string notecard, integer includeHuds)

Save the NPC's current appearance to a notecard in the prim's inventory. This includes body part data, clothing items and attachments. If a notecard with the same name already exists then it is replaced. The avatar must be present in the region when this function is invoked. The baked textures for the avatar (necessary to recreate appearance) are saved permanently.

first variant will include huds on the save appearence. Second variant alloes control of that. incluceHuds 1 (TRUE) will include 0(FALSE) will not

Threat Level High
Permissions ${OSSL|osslNPC}
Extra Delay 0 seconds
Example(s)
//
// osNpcSaveAppearance Script Exemple
// Author: djphil
//
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcSaveAppearance usage.");
    }
 
    collision_start(integer number)
    {
        key collider = llDetectedKey(0);
 
        if (osIsNpc(collider))
        {
            string FullName = osKey2Name(collider);
            list buffer = llParseString2List(FullName, " ", []);
            string FirstName = llList2String(buffer, 0);
            string LastName = llList2String(buffer, 1);
            string NotecardName = FirstName + " " + LastName + " " + llGetTimestamp();
            key result = osNpcSaveAppearance(collider, NotecardName);
 
            if (result && result != NULL_KEY)
            {
                osNpcSay(collider, "Notecard \"" + NotecardName + "\" created with success.");
            }
 
            else
            {
                osNpcSay(collider, "Notecard \"" + NotecardName + "\" created without success.");
            }
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and save their appearance in a notecard ...");
        }
    }
}

And with "includeHuds"

//
// osNpcSaveAppearance Script Exemple
// Author: djphil
//
 
integer includeHuds = TRUE;
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcSaveAppearance usage.");
    }
 
    collision_start(integer number)
    {
        key collider = llDetectedKey(0);
 
        if (osIsNpc(collider))
        {
            string FullName = osKey2Name(collider);
            list buffer = llParseString2List(FullName, " ", []);
            string FirstName = llList2String(buffer, 0);
            string LastName = llList2String(buffer, 1);
            string NotecardName = FirstName + " " + LastName + " " + llGetTimestamp();
 
            key result;
 
            if (includeHuds == TRUE)
            {
                result = osNpcSaveAppearance(collider, NotecardName, TRUE);
            }
 
            else
            {
                result = osNpcSaveAppearance(collider, NotecardName, FALSE);
            }
 
            if (result && result != NULL_KEY)
            {
                osNpcSay(collider, "Notecard \"" + NotecardName + "\" created with success.");
            }
 
            else
            {
                osNpcSay(collider, "Notecard \"" + NotecardName + "\" created without success.");
            }
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and save their appearance in a notecard ...");
        }
    }
}
Notes
This function was added in 0.7.2-post-fixes, huds control added in 0.9.2.0


See Also:

Personal tools
General
About This Wiki