OsAvatarPlayAnimation

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
(17 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<table width="100%" style="border: thin solid black; vertical-align:top">
+
{{osslfunc
<tr>
+
|threat_level=VeryHigh
<td colspan="2" align="center" style="background:orange"> <b><span class="fck_mw_template">{{SUBPAGENAME}}</span></b>
+
|permissions=false
</td></tr>
+
|delay=0
<tr>
+
|function_syntax= osAvatarPlayAnimation(key avatar, string animation)  
<td><b>Threat Level</b> </td><td> High
+
|ossl_example=<source lang="lsl">
</td></tr>
+
//
<tr>
+
// osResetAllScripts Script Example
<td><b>Function Syntax</b> </td><td> <span class="fck_mw_source" _fck_mw_customtag="true" _fck_mw_tagname="source" lang="lsl">fckLRosAvatarPlayAnimation(key avatar, string animation) fckLR</span>
+
//
</td></tr>
+
 
<tr>
+
default
<td><b>Example(s)</td><td><span class="fck_mw_source" _fck_mw_customtag="true" _fck_mw_tagname="source" lang="lsl">fckLR//Example Usage: default { fckLRfckLR    touch_start(integer num) {fckLR      string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);fckLR      osAvatarPlayAnimation(llDetectedKey(0), anim);fckLR  }fckLRfckLR} fckLR</span></b>
+
{
</td></tr></table>
+
    touch_start(integer num)
<p>This function causes an animation to be played on the specified avatar.  
+
    {
</p><p>The variable <i>animation</i> can be either the name of an animation within the task inventory, or it can be the UUID of an animation.  
+
        // Get the name of the animation from the prim's inventory
</p><p><b>osAvatarPlayAnimation</b> does not perform any security checks or request animation permissions from the targeted avatar,
+
        string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
</p><a _fcknotitle="true" href="Category:OSSL_Functions">OSSL_Functions</a> <a _fcknotitle="true" href="Category:OSSL">OSSL</a>
+
       
 +
        // Play the animation on the avatar who touched the object
 +
        osAvatarPlayAnimation(llDetectedKey(0), anim);
 +
    }
 +
}
 +
</source>
 +
|description=This function causes an animation to be played on the specified avatar.  
 +
 
 +
The variable ''animation'' must be the name of an animation within the task inventory. For security reasons, UUIDs are not allowed here.
 +
 
 +
Instead of the name of an animation in the prim's inventory, you can also use the names of the viewer's [http://wiki.secondlife.com/wiki/Internal_Animations built-in animations].
 +
 
 +
'''osAvatarPlayAnimation''' does not perform any security checks or request animation permissions from the targeted avatar.
 +
 
 +
|additional_info= When using this function in an object that requires the user to sit on the object (like a chair,or a poseball), you will need to stop the sit animation by including the following snippet:
 +
<source lang = "lsl">
 +
changed(integer change)
 +
{
 +
    // Check if there's a change in the link set
 +
    if (change & CHANGED_LINK)
 +
    {
 +
        // Get the key of the user sitting on the object
 +
        key user = llAvatarOnSitTarget();
 +
       
 +
        // Stop the sit animation
 +
        osAvatarStopAnimation(user, "sit");
 +
       
 +
        // Play the desired animation on the user
 +
        osAvatarPlayAnimation(user, anim);
 +
    }
 +
}
 +
</source>
 +
|
 +
}}
 +
== See Also ==
 +
* [[osAvatarPlayAnimation]]
 +
* [[osAvatarStopAnimation]]
 +
* [[OSSL_Script_Library/OSSL_Poseball|OSSL_Poseball script]]

Latest revision as of 01:00, 7 March 2024

osAvatarPlayAnimation(key avatar, string animation)
This function causes an animation to be played on the specified avatar.

The variable animation must be the name of an animation within the task inventory. For security reasons, UUIDs are not allowed here.

Instead of the name of an animation in the prim's inventory, you can also use the names of the viewer's built-in animations.

osAvatarPlayAnimation does not perform any security checks or request animation permissions from the targeted avatar.

Threat Level VeryHigh
Permissions Use of this function is always disabled by default
Extra Delay 0 seconds
Example(s)
//
// osResetAllScripts Script Example
//
 
default
{
    touch_start(integer num)
    {
        // Get the name of the animation from the prim's inventory
        string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
 
        // Play the animation on the avatar who touched the object
        osAvatarPlayAnimation(llDetectedKey(0), anim);
    }
}
Notes
When using this function in an object that requires the user to sit on the object (like a chair,or a poseball), you will need to stop the sit animation by including the following snippet:
changed(integer change)
{
    // Check if there's a change in the link set
    if (change & CHANGED_LINK)
    {
        // Get the key of the user sitting on the object
        key user = llAvatarOnSitTarget();
 
        // Stop the sit animation
        osAvatarStopAnimation(user, "sit");
 
        // Play the desired animation on the user
        osAvatarPlayAnimation(user, anim);
    }
}


[edit] See Also

Personal tools
General
About This Wiki