OsAgentSaveAppearance

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
Line 25: Line 25:
 
     state_entry()
 
     state_entry()
 
     {
 
     {
 +
        // Display a message prompting users to touch the object to see how osAgentSaveAppearance is used
 
         llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance usage.");
 
         llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance usage.");
 
     }
 
     }
+
 
 
     touch_start(integer number)
 
     touch_start(integer number)
 
     {
 
     {
 +
        // Get the key of the avatar who touched the object
 
         key toucher = llDetectedKey(0);
 
         key toucher = llDetectedKey(0);
+
 
 +
        // Check if the avatar's size is not zero vector (i.e., if the avatar is present in the same region)
 
         if (llGetAgentSize(toucher) != ZERO_VECTOR)
 
         if (llGetAgentSize(toucher) != ZERO_VECTOR)
 
         {
 
         {
 +
            // Attempt to save the avatar's appearance to a notecard using osAgentSaveAppearance
 
             key result = osAgentSaveAppearance(toucher, (string)toucher);
 
             key result = osAgentSaveAppearance(toucher, (string)toucher);
+
 
 +
            // Check if the result is successful
 
             if (result && result != NULL_KEY)
 
             if (result && result != NULL_KEY)
 
             {
 
             {
 
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved with success.");
 
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved with success.");
 
             }
 
             }
 
 
             else
 
             else
 
             {
 
             {
Line 46: Line 50:
 
             }
 
             }
 
         }
 
         }
 
 
         else
 
         else
 
         {
 
         {
 +
            // Send an instant message to the avatar indicating that they need to be in the same region to use the function
 
             llInstantMessage(toucher, "You need to be in the same region to use this function ...");
 
             llInstantMessage(toucher, "You need to be in the same region to use this function ...");
 
         }
 
         }
Line 61: Line 65:
 
//
 
//
 
   
 
   
 +
// Define a variable to specify whether to include HUD attachments in appearance save
 
integer includeHuds = TRUE;
 
integer includeHuds = TRUE;
+
 
 
default
 
default
 
{
 
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
 +
        // Display a message prompting users to touch the object to see how osAgentSaveAppearance is used with an option
 
         llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance (with option) usage.");
 
         llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance (with option) usage.");
 
     }
 
     }
+
 
 
     touch_start(integer number)
 
     touch_start(integer number)
 
     {
 
     {
 +
        // Get the key of the avatar who touched the object
 
         key toucher = llDetectedKey(0);
 
         key toucher = llDetectedKey(0);
+
 
 +
        // Check if the avatar's size is not zero vector (i.e., if the avatar is present in the same region)
 
         if (llGetAgentSize(toucher) != ZERO_VECTOR)
 
         if (llGetAgentSize(toucher) != ZERO_VECTOR)
 
         {
 
         {
 
             key result;
 
             key result;
+
 
 +
            // Check the includeHuds variable to determine whether to include HUD attachments in appearance save
 
             if (includeHuds == TRUE)
 
             if (includeHuds == TRUE)
 
             {
 
             {
 
                 result = osAgentSaveAppearance(toucher, (string)toucher, TRUE);
 
                 result = osAgentSaveAppearance(toucher, (string)toucher, TRUE);
 
             }
 
             }
 
 
             else
 
             else
 
             {
 
             {
 
                 result = osAgentSaveAppearance(toucher, (string)toucher, FALSE);
 
                 result = osAgentSaveAppearance(toucher, (string)toucher, FALSE);
 
             }
 
             }
+
 
 +
            // Check if the result is successful
 
             if (result && result != NULL_KEY)
 
             if (result && result != NULL_KEY)
 
             {
 
             {
 
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved with success.");
 
                 llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved with success.");
 
             }
 
             }
 
 
             else
 
             else
 
             {
 
             {
Line 98: Line 106:
 
             }
 
             }
 
         }
 
         }
 
 
         else
 
         else
 
         {
 
         {
 +
            // Send an instant message to the avatar indicating that they need to be in the same region to use the function
 
             llInstantMessage(toucher, "You need to be in the same region to use this function ...");
 
             llInstantMessage(toucher, "You need to be in the same region to use this function ...");
 
         }
 
         }

Latest revision as of 01:56, 7 March 2024

key osAgentSaveAppearance(key agentId, string notecard)

key osAgentSaveAppearance(key agentId, string notecard, integer includeHuds)

Save an arbitrary avatar's 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 on the NPC) are saved permanently.

The first variant will include HUDs, the second variant allows control that. incluceHuds 1 (TRUE) will include 0(FALSE) will not

Threat Level VeryHigh
Permissions ESTATE_MANAGER,ESTATE_OWNER
Extra Delay 0 seconds
Example(s)
//
// osAgentSaveAppearance Script Example
// Author: djphil
//
 
default
{
    state_entry()
    {
        // Display a message prompting users to touch the object to see how osAgentSaveAppearance is used
        llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance usage.");
    }
 
    touch_start(integer number)
    {
        // Get the key of the avatar who touched the object
        key toucher = llDetectedKey(0);
 
        // Check if the avatar's size is not zero vector (i.e., if the avatar is present in the same region)
        if (llGetAgentSize(toucher) != ZERO_VECTOR)
        {
            // Attempt to save the avatar's appearance to a notecard using osAgentSaveAppearance
            key result = osAgentSaveAppearance(toucher, (string)toucher);
 
            // Check if the result is successful
            if (result && result != NULL_KEY)
            {
                llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved with success.");
            }
            else
            {
                llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved without success.");
            }
        }
        else
        {
            // Send an instant message to the avatar indicating that they need to be in the same region to use the function
            llInstantMessage(toucher, "You need to be in the same region to use this function ...");
        }
    }
}

And with "includeHuds"

//
// osAgentSaveAppearance (with option) Script Example
// Author: djphil
//
 
// Define a variable to specify whether to include HUD attachments in appearance save
integer includeHuds = TRUE;
 
default
{
    state_entry()
    {
        // Display a message prompting users to touch the object to see how osAgentSaveAppearance is used with an option
        llSay(PUBLIC_CHANNEL, "Touch to see osAgentSaveAppearance (with option) usage.");
    }
 
    touch_start(integer number)
    {
        // Get the key of the avatar who touched the object
        key toucher = llDetectedKey(0);
 
        // Check if the avatar's size is not zero vector (i.e., if the avatar is present in the same region)
        if (llGetAgentSize(toucher) != ZERO_VECTOR)
        {
            key result;
 
            // Check the includeHuds variable to determine whether to include HUD attachments in appearance save
            if (includeHuds == TRUE)
            {
                result = osAgentSaveAppearance(toucher, (string)toucher, TRUE);
            }
            else
            {
                result = osAgentSaveAppearance(toucher, (string)toucher, FALSE);
            }
 
            // Check if the result is successful
            if (result && result != NULL_KEY)
            {
                llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved with success.");
            }
            else
            {
                llSay(PUBLIC_CHANNEL, "Notecard \"" + (string)toucher + "\" saved without success.");
            }
        }
        else
        {
            // Send an instant message to the avatar indicating that they need to be in the same region to use the function
            llInstantMessage(toucher, "You need to be in the same region to use this function ...");
        }
    }
}
Notes
This function was added in 0.7.2-post-fixes, huds control added in 0.9.2


[edit] See Also

Personal tools
General
About This Wiki