Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Free, open-source pose ball code for anims - EASY, low lag!

FlipperPA Peregrine
Magically Delicious!
Join date: 14 Nov 2003
Posts: 3,703
06-11-2005 18:05
This should work great for furniture, hang out areas, and more. There are two versions of the script below:

(1) The "no listener" version. This will automatically turn transparent and solid when used. It automatically reads the animation in inventory so you should have to modify anything other than the "Sit Replacement Text" at the top. This will cause almost no lag to your sim.

(2) The "listener" version. This contains a listener on channel 1, which replies to a "show / hide" command from anyone. This is handy for poseballs which may need to be moved or positioned AFTER the avatar is actively posed.

Another advantage: I'm calling the transparent and solid textures by key, so you don't have to put any textures into the prim's inventory - just the script and the animation you want triggered. I'm sure they can be improved a bit, but here they are.

The NO LISTENER version (recommended; minimum lag):
CODE

// FlipperPA's auto-transparent minimum lag pose thingy.

// STEP 1: Drop your pose into an object inventory with this script (only 1)
// STEP 2: Simply enter the text you wish to hover about the pose object below

string DISPLAY_TEXT = "Float";

// STEP 3: Hit "SAVE" below. If you change the pose, you can reset the script to re-read the pose

/////////////////////// DO NOT CHANGE BELOW ////////////////////////
string ANIMATION;
integer is_sitting;

default
{
state_entry()
{
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, 0);
is_sitting = 0;
llSitTarget(<0,0,.1>,ZERO_ROTATION);
llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);
llSetText(DISPLAY_TEXT,<1,1,1>,1);
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();

if(av != NULL_KEY)
{
llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
}
else
{
if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && is_sitting)
{
is_sitting = 0;
llStopAnimation(ANIMATION);
llSetText(DISPLAY_TEXT,<1,1,1>,1);
llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);
}
}

}
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, 0);
}

run_time_permissions(integer perm)
{
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
is_sitting = 1;
llStopAnimation("sit_generic");
llStopAnimation("sit");
llStartAnimation(ANIMATION);
llSetTexture("f54a0c32-3cd1-d49a-5b4f-7b792bebc204",ALL_SIDES);
llSetText("",<1,1,1>,1);
}
}

on_rez(integer start_param)
{
llResetScript();
}
}


The LISTENER version (only use if necessary):
CODE

// FlipperPA's auto-transparent minimum lag pose thingy.

// STEP 1: Drop your pose into an object inventory with this script (only 1)
// STEP 2: Simply enter the text you wish to hover about the pose object below

string DISPLAY_TEXT = "Sit Here!";

// STEP 3: Hit "SAVE" below. If you change the pose, you can reset the script to re-read the pose
// by typing "/1 reset" into chat within listen range of the script.



/////////////////////// DO NOT CHANGE BELOW ////////////////////////
string ANIMATION;
integer is_sitting;

default
{
state_entry()
{
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, 0);
is_sitting = 0;
llListen(1,"","","");
llSitTarget(<0,0,.1>,ZERO_ROTATION);
llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);

llSetText(DISPLAY_TEXT,<1,1,1>,1);
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();

if(av != NULL_KEY)
{
llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
}
else
{
if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && is_sitting)
{
is_sitting = 0;
llStopAnimation(ANIMATION);
llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);
llSetText(DISPLAY_TEXT,<1,1,1>,1);
}
}
}
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, 0);
}

run_time_permissions(integer perm)
{
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
is_sitting = 1;
llStopAnimation("sit_generic");
llStopAnimation("sit");
llStartAnimation(ANIMATION);
llSetTexture("f54a0c32-3cd1-d49a-5b4f-7b792bebc204",ALL_SIDES);
llSetText("",<1,1,1>,1);
}
}

listen(integer channel, string name, key id, string message)
{
if(!is_sitting)
{
if(message == "show")
{
llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);
llSetText(DISPLAY_TEXT,<1,1,1>,1);
}
else if(message == "hide")
{
llSetTexture("f54a0c32-3cd1-d49a-5b4f-7b792bebc204",ALL_SIDES);
llSetText("",<1,1,1>,1);
}
else if(message == "reset" && id == llGetOwner())
{
llResetScript();
}
}
}

on_rez(integer start_param)
{
llResetScript();
}
}


You should be able to do a drop and replace of most pose code out there to reduce lag, but no promises, no warranties. Standard disclaimer, etc. Do with them as you will. If you improve anything within the code, be sure to contribute back to the code. :-)

Thanks & Enjoy,

-Flip
_____________________
Peregrine Salon: www.PeregrineSalon.com - my consulting company
Second Blogger: www.SecondBlogger.com - free, fully integrated Second Life blogging for all avatars!
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Post
06-12-2005 20:38
/54/04/50071/1.html
_____________________
i've got nothing. ;)