Difference between revisions of "LlGetAnimation"

From Second Life Wiki
Jump to: navigation, search
m
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Multi-lang}}
+
{{LSL_Function
{{LSL Function/avatar|id|sim=*}}{{LSL_Function
+
|inject-2={{LSL Function/avatar|id|sim=*}}
 
|func_id=162|func_sleep=0.0|func_energy=10.0
 
|func_id=162|func_sleep=0.0|func_energy=10.0
 
|func=llGetAnimation|return_type=string|p1_type=key|p1_name=id
 
|func=llGetAnimation|return_type=string|p1_type=key|p1_name=id
|func_footnote=[[llGetAgentInfo]] and [[llGetAnimationList]] provide more detailed information about the avatar state then this function does, it is recommended that you use them instead.
+
|func_footnote=[[llGetAgentInfo]] provides information on some animation states not covered by this function (typing, away, busy). [[llGetAnimationList]] provides more detailed information about the running animations, but may not reflect avatar state as accurately as llGetAnimation.
 
|func_desc
 
|func_desc
|return_text=that is the name of the currently playing locomotion animation for avatar '''id'''. See the table below.
+
|return_text=that is the name of the currently playing locomotion animation for avatar {{LSLP|id}}. See the table below.
 
|spec
 
|spec
|caveats
+
|caveats=*This function can return an empty string while the avatar is logging out.
|constants={{{!}}
+
*New return values could conceivably be added at any time and this list may not in-fact be complete. Scripts should be written under the assumption that they may receive a value they won't recognize.
 +
|constants=
 +
{{{!}} id="Constants"
 +
{{!}}+ '''Complete list of return values as of August 15, 2011.'''{{Footnote|With the successful conclusion of {{jira|SCR-26}}, a complete list of values was posted; however no indication was given as to which of the previously undocumented codes are active but just uncommon.|With the successful conclusion of SCR-26, a complete list of values was posted; however no indication was given as to which of the previously undocumented codes are active but just uncommon.}}
 
{{!}}-valign="top"
 
{{!}}-valign="top"
 
{{!}}
 
{{!}}
{{{!}}{{Prettytable}}
+
{{LSL Animation States|title={{LSLGC|Animation/Override|Overridable}} values}}
 +
{{!}}
 +
{{{!}} class="sortable" {{Prettytable|style=margin-top:0;}}
 +
{{!}}+Other Common/Active values
 
{{!}}-{{Hl2}}
 
{{!}}-{{Hl2}}
 
!Value
 
!Value
 
!Description
 
!Description
 
{{!}}-
 
{{!}}-
{{!}}"Crouching"
+
{{!}}""
 +
{{!}}During logout
 +
{{!}}-
 +
{{!}}"Init"
 +
{{!}}At login and after teleports.
 +
{{!}}}
 
{{!}}
 
{{!}}
 +
{{{!}} class='sortable' {{Prettytable|style=margin-top:0;}}
 +
{{!}}+Uncommon/Inactive return values
 +
{{!}}-{{Hl2}}
 +
!Value
 +
!Description
 
{{!}}-
 
{{!}}-
{{!}}"Hovering"
+
{{!}}"Crouch"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Hovering Down"
+
{{!}}"Epsilon"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Hovering Up"
+
{{!}}"Fall Down Land"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Jumping"
+
{{!}}"Finish Animation"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"PreJumping"
+
{{!}}"Fly"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Running"
+
{{!}}"FlySlow"
 
{{!}}
 
{{!}}
{{!}}}
+
{{!}}-
 +
{{!}}"Hard Land"
 
{{!}}
 
{{!}}
{{{!}}{{Prettytable}}
 
{{!}}-{{Hl2}}
 
!Value
 
!Description
 
 
{{!}}-
 
{{!}}-
{{!}}"Sitting"
+
{{!}}"Hover Down"
{{!}}Sitting on an object.
+
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Sitting on Ground"
+
{{!}}"Hover Up"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Standing"
+
{{!}}"Hover"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Striding"
+
{{!}}"Medium Land"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Flying"
+
{{!}}"PreFlying"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"FlyingSlow"
+
{{!}}"PreJump"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Falling Down"
+
{{!}}"Prep For Teleport"
 
{{!}}
 
{{!}}
{{!}}}
+
{{!}}-
 +
{{!}}"Run"
 
{{!}}
 
{{!}}
{{{!}}{{Prettytable}}
 
{{!}}-{{Hl2}}
 
!Value
 
!Description
 
 
{{!}}-
 
{{!}}-
{{!}}"Standing Up"
+
{{!}}"Sit on Ground"
{{!}}After falling from a great distance.
+
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Landing"
+
{{!}}"Sit"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Soft Landing"
+
{{!}}"Soft Land"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"CrouchWalking"
+
{{!}}"Stand"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Turning Left"
+
{{!}}"Stride"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Turning Right"
+
{{!}}"Take Off"
 
{{!}}
 
{{!}}
 
{{!}}-
 
{{!}}-
{{!}}"Walking"
+
{{!}}"Turn Done"
 
{{!}}
 
{{!}}
 +
{{!}}-
 +
{{!}}"Turn Left"
 +
{{!}}
 +
{{!}}-
 +
{{!}}"Turn Right"
 +
{{!}}
 +
{{!}}-
 +
{{!}}"Uncrouch"
 +
{{!}}
 +
{{!}}-
 +
{{!}}"Walk"
 +
{{!}}
 +
{{!}}-
 
{{!}}}
 
{{!}}}
 
{{!}}}
 
{{!}}}
|examples
+
|examples=
 +
<source lang="lsl2">
 +
// A simple animation override example.
 +
// Make the avatar run in mid-air when jumping.
 +
 
 +
key gOwner; // the wearer's key
 +
string gLastAnimation; // last llGetAnimation value seen
 +
 
 +
// User functions
 +
 
 +
Initialize(key id) {
 +
    if (id == NULL_KEY) { // detaching
 +
        llSetTimerEvent(0.0); // stop the timer
 +
    }
 +
    else { // attached, or reset while worn
 +
        llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
 +
        gOwner = id;
 +
    }
 +
}
 +
 
 +
 
 +
// Event handlers
 +
 
 +
default
 +
{
 +
    state_entry() {
 +
        // in case the script was reset while already attached
 +
        if (llGetAttached() != 0) {
 +
            Initialize(llGetOwner());
 +
        }
 +
    }
 +
 
 +
    attach(key id) {
 +
        Initialize(id);
 +
    }
 +
 
 +
    run_time_permissions(integer perm) {
 +
        if (perm & PERMISSION_TRIGGER_ANIMATION) {
 +
            llSetTimerEvent(0.25); // start polling
 +
        }
 +
    }
 +
 
 +
    timer() {
 +
        string newAnimation = llGetAnimation(gOwner);
 +
 
 +
        if (gLastAnimation != newAnimation) { // any change?
 +
            if (newAnimation == "Jumping") {
 +
               
 +
                // You can stop the built-in animation if you like, if
 +
                // it might interfere with your own. Be aware that an
 +
                // avatar can become stuck, and some llGetAgentInfo results
 +
                // can be inaccurate, if you stop built-ins indiscriminately.
 +
                // Always test.
 +
                //
 +
                // llStopAnimation("jump");
 +
   
 +
                llStartAnimation("run");
 +
            }
 +
            else if (gLastAnimation == "Jumping")  { // just finished jumping
 +
                // "run" is looped, so we have to stop it when we are done.
 +
                llStopAnimation("run");
 +
            }
 +
           
 +
            gLastAnimation = newAnimation; // store away for  next time
 +
        }
 +
    }
 +
}
 +
</source>
 
|helpers
 
|helpers
 
|also_functions={{LSL DefineRow||[[llGetAgentInfo]]|}}
 
|also_functions={{LSL DefineRow||[[llGetAgentInfo]]|}}

Latest revision as of 01:37, 22 January 2015

Summary

Function: string llGetAnimation( key id );

Returns a string that is the name of the currently playing locomotion animation for avatar id. See the table below.

• key id avatar UUID that is in the same region

llGetAgentInfo provides information on some animation states not covered by this function (typing, away, busy). llGetAnimationList provides more detailed information about the running animations, but may not reflect avatar state as accurately as llGetAnimation.

Complete list of return values as of August 15, 2011.[1]
Overridable values
Value Type Description Default
"Crouching" State crouch
"CrouchWalking" State crouchwalk
"Falling Down" State falldown
"Flying" State fly
"FlyingSlow" State flyslow
"Hovering" State hover
"Hovering Down" State hover_down
"Hovering Up" State hover_up
"Jumping" State While still in the air during a jump. jump
"Landing" Transition When landing from a jump. land
"PreJumping" Transition At the beginning of a jump. prejump
"Running" State run
"Sitting" State Sitting on an object (and linked to it). sit
"Sitting on Ground" State Sitting, but not linked to an object.[2] sit_ground_constrained
"Standing" State stand
"Standing Up" Transition After falling a great distance. Sometimes referred to as Hard Landing. standup
"Striding" State When the avatar is stuck on the edge of an object or on top of another avatar. stride
"Soft Landing" Transition After falling a small distance. soft_land
"Taking Off" State hover_up
"Turning Left" State turnleft
"Turning Right" State turnright
"Walking" State walk
Other Common/Active values
Value Description
"" During logout
"Init" At login and after teleports.
Uncommon/Inactive return values
Value Description
"Crouch"
"Epsilon"
"Fall Down Land"
"Finish Animation"
"Fly"
"FlySlow"
"Hard Land"
"Hover Down"
"Hover Up"
"Hover"
"Medium Land"
"PreFlying"
"PreJump"
"Prep For Teleport"
"Run"
"Sit on Ground"
"Sit"
"Soft Land"
"Stand"
"Stride"
"Take Off"
"Turn Done"
"Turn Left"
"Turn Right"
"Uncrouch"
"Walk"

Caveats

  • This function can return an empty string while the avatar is logging out.
  • New return values could conceivably be added at any time and this list may not in-fact be complete. Scripts should be written under the assumption that they may receive a value they won't recognize.
All Issues ~ Search JIRA for related Bugs

Examples

// A simple animation override example.
// Make the avatar run in mid-air when jumping.
 
key gOwner; // the wearer's key
string gLastAnimation; // last llGetAnimation value seen
 
// User functions
 
Initialize(key id) {
    if (id == NULL_KEY) { // detaching
        llSetTimerEvent(0.0); // stop the timer
    }
    else { // attached, or reset while worn
        llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
        gOwner = id;
    }
}
 
 
// Event handlers
 
default
{
    state_entry() {
        // in case the script was reset while already attached
        if (llGetAttached() != 0) {
            Initialize(llGetOwner());
        }
    }
 
    attach(key id) {
        Initialize(id);
    }
 
    run_time_permissions(integer perm) {
        if (perm & PERMISSION_TRIGGER_ANIMATION) {
            llSetTimerEvent(0.25); // start polling
        }
    }
 
    timer() {
        string newAnimation = llGetAnimation(gOwner);
 
        if (gLastAnimation != newAnimation) { // any change?
            if (newAnimation == "Jumping") {
 
                // You can stop the built-in animation if you like, if
                // it might interfere with your own. Be aware that an
                // avatar can become stuck, and some llGetAgentInfo results
                // can be inaccurate, if you stop built-ins indiscriminately.
                // Always test.
                //
                // llStopAnimation("jump");
 
                llStartAnimation("run");
            }
            else if (gLastAnimation == "Jumping")  { // just finished jumping
                // "run" is looped, so we have to stop it when we are done.
                llStopAnimation("run");
            }
 
            gLastAnimation = newAnimation; // store away for  next time
        }
    }
}

See Also

Functions

•  llGetAgentInfo
•  llGetAnimationList

Deep Notes

Search JIRA for related Issues

Footnotes

  1. ^ With the successful conclusion of SCR-26, a complete list of values was posted; however no indication was given as to which of the previously undocumented codes are active but just uncommon.
  2. ^ "Sit down" on the avatar context menu allows ground sits anywhere: atop the terrain, objects or even in the air.

Signature

function string llGetAnimation( key id );