CHAPTER 1
CHAPTER 3
CHAPTER 4
CHAPTER 5
CHAPTER 6
CHAPTER 7
CHAPTER 9
CHAPTER 10
CHAPTER 11
CHAPTER 12
CHAPTER 13
CHAPTER 14
CHAPTER 15
APPENDIC
E
S
57
CHAPTER 2
integer llGetPermissions()
Returns an integer bit pattern with the permissions the script has been granted. Permissions can be
tested with a bitwise "and" operator (&), as shown in the following snippet:
integer grantedPerms = llGetPermissions();
if (grantedPerms & PERMISSION_TAKE_CONTROLS) {
llOwnerSay("Script has permission to take controls.");
}
DEFINITION
key llGetPermissionsKey()
Returns the key of the avatar that granted permissions.
DEFINITION
ANIMATION
An animation is a set of instructions that cause an avatar to engage in a sequence of motions. An animation
describes the way your avatar walks, dances, waves hello, or even sits down. One of the first things that
people notice when they start out in Second Life is how awkward and artificial the default avatar animations
look. So early in an avatar's life, people want to upgrade by adding an animation override, or AO, that
replaces the default settings with higher-quality, more realistic, or special-purpose animations.
You can create your own custom animations with tools such as Poser (http://graphics.
smithmicro.com/go/poser) and Blender (www.blender.org), and then upload them into SL.
Additionally, many high-quality animations are available in-world, many of them for free. Search for
Animation in the All tab of the search window. Many people purchase a set of animators that have been
packaged in a wearable attachment with an AO script, ready to go.
NOTE
CHAPTER 2
58
MOVING
YOUR AVATAR
AROUND THE
WORLD
ATTACHMENTS
ANIMATION
CONTROLLING
YOUR
ATTACHMENTS
SUMMARY
ANIMATION OVERRIDES
The various AO scripts differ in relatively minor ways, but the basic idea is always the same: to watch
what your avatar is doing, and override the default animation with one of your choice. Listing 2.10 replaces
the default walking animation with a floating crossed-leg pose; this is possibly the simplest AO script. It
may look pretty complicated, but we'll walk through the pieces slowly. Place the script in any attachment,
such as a bracelet or a transparent hat. Most of the complexity comes from setting up permissions to
animate the avatarextending the methods shown in Listing 2.10and that is functionality you will use
in a lot of places.
Listing 2.10: WalkAO—Why Walk When You Can Float?
// the animation we're going to override
string AN_TRIGGER = "Walking";
// which animation are we overriding walking with?
string AN_OVERRIDE = "yoga_float";
integer gOverriding = FALSE; // are we running the override right now?
integer gHasPermission = FALSE; // did we get permission yet?
integer gEnabled = TRUE; // is the AO on?
animOverride() {
if (gHasPermission) {
string curAnimState = llGetAnimation(llGetOwner());
if (curAnimState == AN_TRIGGER && gEnabled) {
if (!gOverriding) { // already overriding? skip
gOverriding = TRUE;
llStartAnimation(AN_OVERRIDE);
}
} else {
if (gOverriding) {
llStopAnimation(AN_OVERRIDE);
gOverriding = FALSE;
}
}
}
}
default {
on_rez( integer _code ) {
llResetScript();
}
state_entry() {
gOverriding = FALSE;
gHasPermission = FALSE;
gEnabled = TRUE;
if ( llGetAttached() ) {
llRequestPermissions(llGetOwner(),
PERMISSION_TRIGGER_ANIMATION|
PERMISSION_TAKE_CONTROLS);
}
llSetTimerEvent(1.0);

Get Scripting Your World: The Official Guide to Second Life® Scripting now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.