OsNpcSaveAppearance

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Change See Also)
 
(8 intermediate revisions by one user not shown)
Line 9: Line 9:
 
|ossl_example=
 
|ossl_example=
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
 
 
//
 
//
// osNpcSaveAppearance Script Example
+
// osNpcSaveAppearance Script Exemple
 +
// Author: djphil
 
//
 
//
  
// 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
 
default
 
{
 
{
     touch_start(integer number)
+
     state_entry()
 
     {
 
     {
         vector npcPos = llGetPos() + <1,0,0>;
+
         llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcSaveAppearance usage.");
        osAgentSaveAppearance(llDetectedKey(0), "appearance");
+
    }
         // coud use avatar UUID directly in osNpcCreate, but then NPC appearance is not persisted
+
 
         npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
+
    collision_start(integer number)
         toucherPos = llDetectedPos(0);
+
    {
         state hasNPC;
+
        key collider = llDetectedKey(0);
 +
 
 +
         if (osIsNpc(collider))
 +
         {
 +
            key result = osNpcSaveAppearance(collider, (string)collider);
 +
 
 +
            if (result && result != NULL_KEY)
 +
            {
 +
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved with success.");
 +
            }
 +
 
 +
            else
 +
            {
 +
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved without success.");
 +
            }
 +
         }
 +
 
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and save their appearance in a notecard ...");
 +
         }
 
     }
 
     }
 
}
 
}
+
</source>
state hasNPC
+
'''And with "includeHuds"'''
 +
<source lang="lsl">
 +
//
 +
// osNpcSaveAppearance Script Exemple
 +
// Author: djphil
 +
//
 +
 
 +
integer includeHuds = TRUE;
 +
 
 +
default
 
{
 
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         osNpcMoveTo(npc, toucherPos + <3,0,0>);
+
         llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcSaveAppearance usage.");
        osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc));
+
 
     }
 
     }
+
 
     touch_start(integer number)
+
     collision_start(integer number)
 
     {
 
     {
         osNpcSay(npc, "Goodbye!");
+
         key collider = llDetectedKey(0);
        osNpcRemove(npc);
+
 
         npc = NULL_KEY;
+
        if (osIsNpc(collider))
         state default;
+
        {
 +
            key result;
 +
 
 +
            if (includeHuds == TRUE)
 +
            {
 +
                result = osNpcSaveAppearance(collider, (string)collider, TRUE);
 +
            }
 +
 
 +
            else
 +
            {
 +
                result = osNpcSaveAppearance(collider, (string)collider, FALSE);
 +
            }
 +
 
 +
            if (result && result != NULL_KEY)
 +
            {
 +
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved with success.");
 +
            }
 +
 
 +
            else
 +
            {
 +
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved without success.");
 +
            }
 +
         }
 +
 
 +
         else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and save their appearance in a notecard ...");
 +
        }
 
     }
 
     }
 
}
 
}
 
 
</source>
 
</source>
 
|additional_info=This function was added in 0.7.2-post-fixes, huds control added in 0.9.2.0
 
|additional_info=This function was added in 0.7.2-post-fixes, huds control added in 0.9.2.0
 
}}
 
}}
 +
== See Also ==
 +
* [[osNpcLoadAppearance]]
 +
* [[osNpcSaveAppearance]]
 +
* [[osAgentSaveAppearance]]

Latest revision as of 18:52, 5 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))
        {
            key result = osNpcSaveAppearance(collider, (string)collider);
 
            if (result && result != NULL_KEY)
            {
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved with success.");
            }
 
            else
            {
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved 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))
        {
            key result;
 
            if (includeHuds == TRUE)
            {
                result = osNpcSaveAppearance(collider, (string)collider, TRUE);
            }
 
            else
            {
                result = osNpcSaveAppearance(collider, (string)collider, FALSE);
            }
 
            if (result && result != NULL_KEY)
            {
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved with success.");
            }
 
            else
            {
                osNpcSay(collider, "Notecard \"" + (string)collider + "\" saved 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


[edit] See Also

Personal tools
General
About This Wiki