Difference between revisions of "LlGetAnimation"
Jump to navigation
Jump to search
All Issues ~ Search JIRA for related Bugs
Line 95: | Line 95: | ||
{{!}}} | {{!}}} | ||
{{!}}} | {{!}}} | ||
|examples | |examples= | ||
<lsl> | |||
// A simple animation override example. | |||
// Make the avatar do backflips when jumping. | |||
key gOwner; //the wearer's key | |||
// 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() { | |||
if (llGetAnimation(gOwner) == "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("backflip"); | |||
} | |||
} | |||
} | |||
</lsl> | |||
|helpers | |helpers | ||
|also_functions={{LSL DefineRow||[[llGetAgentInfo]]|}} | |also_functions={{LSL DefineRow||[[llGetAgentInfo]]|}} |
Revision as of 03:13, 2 May 2009
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string llGetAnimation( key id );162 | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
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.
|
|
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.
Examples
<lsl> // A simple animation override example. // Make the avatar do backflips when jumping.
key gOwner; //the wearer's key
// 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() { if (llGetAnimation(gOwner) == "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("backflip"); } }
}
</lsl>See Also
Functions
• | llGetAgentInfo | |||
• | llGetAnimationList |