Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Multi-Pose Animation Stand

Teddy Wishbringer
Snuggly Bear Cub
Join date: 28 Nov 2004
Posts: 208
03-08-2006 08:11
After getting frustrated going through all the hundreds of animations in my inventory on at a time (dbl-click, play locally, close, dbl-click, play locally, etc...) I decided I wanted a stand that I could put all my animations (aka poses) into, and like a animation vendor, simply click on a next and back button to cycle through them all.

I've made the script public and free, and heavily commented it so anyone with basic scripting experience should be able to follow along. This is my second script written from scratch, and I'm quite thrilled to present it to you for your use.

Instructions:

Create a prim for the stand, and two prims for the next and back buttons. Make sure those buttons are labelled 'next' and 'back'. Link all three prims together making the stand the root prim. To do this, make sure the stand is the last prim selected before linking them. Put the code below into the linked object, as well as as many poses in your inventory as you want.

The stand will whisper the number of poses loaded in the stand, and to play them, it's just a matter of right clicking on the stand and select 'Pose'. The next and back buttons will change animations, and hover text will tell you the name of the pose currently playing.

Enjoy!

Teddy.

CODE
// Animation Stand (Stand Script)
// by Teddy Wishbringer
//
// Thanks go to Argent Stonecutter for assistance in streamlining and bug squishing. :)
//
// Allows owner to cycle through all the animations stored within the stand by
// clicking on BACK and NEXT buttons. This script goes in the stand, which
// should be the root prim in the linkset. Linkset requires two additional
// prim buttons (forward and backward) with each named 'next' and 'back' respectively.
//
// NOTE: This script is made free, and may be destributed as long as you
// do not charge for it, the comments remain untouched and this script
// remains end-user modifiable.


// User adjustable settings

vector animation_offset = <0,0,1.5>; // Animation offset from stand
string base_float_text = "Now playing animation: "; // Float text prefix
vector color_float_text = <1,1,1>; // Floating text colour
float alpha_float_text = 1.0; // Floating text alpha transparency

// System settings - Do Not Change Anything Below!

integer animation_qty; // Number of animations available
integer animation_current; // Inventory number of current animation
string animation_name; // Name of current animation
string new_animation_name; // Name of next animation.
string float_text; // Used when we evaluate the entire floating text message
key avatar; // Key of the avatar who's sitting on me

update_inventory()
{
llSetText("Updating animation list...", color_float_text,alpha_float_text);
animation_qty = llGetInventoryNumber(INVENTORY_ANIMATION); // Check how many anims we have?
if (animation_qty > 0)
{
llWhisper(0, "Total animations loaded in this stand: " + (string)animation_qty);
set_anim(0);
}
else
{
llSetText("No Animations Found.. Offline", color_float_text,alpha_float_text);
}
}

// Set the next animation available as the active one
set_anim(integer inventory_number)
{
// Get the name of the animation is inventory position (inventory_number)
new_animation_name = llGetInventoryName(INVENTORY_ANIMATION,inventory_number);
// Update the floating text to display new animation, and the number out of total available
float_text = base_float_text + new_animation_name + "\n(" + (string)(animation_current + 1) + " of " + (string)animation_qty + ")";
llSetText(float_text, color_float_text,alpha_float_text);

// Get the key of the avatar on the stand (or if none is present)
avatar = llAvatarOnSitTarget();

if (avatar != NULL_KEY) // Is avatar is still posing, if so then..
{
llStopAnimation(animation_name); // Stop current animation
llStartAnimation(new_animation_name); // Start next animation
}
// Set the new animation name as the current
animation_name = new_animation_name;
}

default
{

on_rez(integer num)
{
llResetScript(); // Reset the script
}

state_entry()
{
update_inventory(); // Perform an inventory update and determine how many animations we have

if (animation_qty > 0)
{
llSetSitText("Pose");
llSitTarget(animation_offset,ZERO_ROTATION);
animation_name = llGetInventoryName(INVENTORY_ANIMATION, 0);
set_anim(animation_current);
}

}

// If touched, detect touch location and do the right thing
touch_start(integer num)
{
// Get the name of the prim touched
string where = llGetLinkName(llDetectedLinkNumber(0));

if (where == "next") // The next button was pressed
{
animation_current++; // Increment the animation inventory pointer
if ((animation_current + 1) > animation_qty) // Have we reached the last animation in the object?
{
animation_current = 0; // We have, so wrap around back to the first one
}
set_anim(animation_current);
}
else if (where == "back") // The back button was pressed
{
animation_current--; // Decrement the animation inventory pointer
if (animation_current < 0) // Have we reached the first animation in the object?
{
animation_current = animation_qty - 1; // We have, so wrap around to the last one
}

set_anim(animation_current); // Update the animation played by the stand
}
}

changed(integer change)
{
if (change & CHANGED_INVENTORY) // Test for a changed inventory
{
update_inventory();
}

// The object's sit target has been triggered
if (change & CHANGED_LINK) // Test for a changed link
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY) // Is that changed link an avatar?
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animation_name);
}
}
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(animation_name);
} // other permission checks would follow
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
03-09-2006 20:47
/15/26/92321/1.html
_____________________
i've got nothing. ;)
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
03-10-2006 08:34
From: Nada Epoch

You need to change one line... just in case people extend the code to do things that require more permissions, similar to the code in your change handler.

CODE

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(animation_name);
} // other permission checks would follow
}
Teddy Wishbringer
Snuggly Bear Cub
Join date: 28 Nov 2004
Posts: 208
03-10-2006 09:02
Fixed.. thank you.
Doubledown Tandino
ADULT on the Mainland!
Join date: 9 Mar 2006
Posts: 1,020
02-05-2007 20:44
Would you be able to provide the script if I wanted the animations to cycle through automatically? No next/back options... just sit and then they automatically cycle through.

If you can provide that also, that'd be great
_____________________
http://djdoubledown.blogspot.com
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
02-05-2007 22:36
What is the trigger to change animation? Time? Like every 5 seconds?
_____________________
:) Seagel Neville :)
Tarina Sewell
Just Browsing Thank you
Join date: 20 Jul 2007
Posts: 2,180
Question on this
10-14-2007 14:17
This is very much the script I need, but I can not get it to work. I have followed all the directions exactly. I do not get a "pose" when clicked. Only sit here and I actually sit there.. Please help.
I will probably loose this post, so please contact me in world if you can.

Tarina Sewell
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-14-2007 14:43
From: Tarina Sewell
This is very much the script I need, but I can not get it to work. I have followed all the directions exactly. I do not get a "pose" when clicked. Only sit here and I actually sit there.. Please help.
I will probably loose this post, so please contact me in world if you can.

Tarina Sewell

Did you create the "next" & "back" buttons and link them to the pose stand?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Tarina Sewell
Just Browsing Thank you
Join date: 20 Jul 2007
Posts: 2,180
10-14-2007 22:41
Yes I did.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-15-2007 15:52
The script works just fine. I created 3 objects w/ 1 named "back", 1 named "next". In edit, I picked the two button prim and the main prim last and linked them. Put 5 dances in the central prim and put the script in. It said "5 animations loaded" and touching back or next brings up the next anim. When I right clicked the main prim it had "Pose" in the pie menu and when that was clicked I was on the prim. Of course nothing happened until I turned off my AO. Once it was off I started dancing and touching either button had me start the next dance.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Tarina Sewell
Just Browsing Thank you
Join date: 20 Jul 2007
Posts: 2,180
10-15-2007 17:07
I to have done just that.. no differences.

I give up. It does not work for me. I will find something else to use.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-15-2007 17:21
Hey don't give up on us. We were all at the same point you were when we began.

Did you notice that the script was not saving and was throwing a compiler error? If a script can't be saved then it can't run. There are two places in the script above that there are spaces that shouldn't be there. It is a fairly common occurence when posting a script here. The first is line number #15:

new_animation_name = llGetInventoryName(INVENTORY_ANIMATION,inventory_n umber);

The second is at line #130:

llRequestPermissions(avatar,PERMISSION_TRIGGER_ANI MATION);

Take the spaces out and the script will save and compile.

After you save the script then make sure the Script running box is checked on the bottom right of the script window. You know you have it right when the script tells you how many animations it has in it.

Again don't give up. You had the courage to take the first step and create a scripted object instead of just being a consumer in SL. Hang in there and in no time you'll be hooked on scripting.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Tarina Sewell
Just Browsing Thank you
Join date: 20 Jul 2007
Posts: 2,180
10-16-2007 13:46
I won't give up and appreciate the help.
I get (50, 72 ) error syntax error
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-16-2007 14:31
From: Tarina Sewell
I won't give up and appreciate the help.
I get (50, 72 ) error syntax error

Great! Then we are almost there! Change this part of line 50:

new_animation_name = llGetInventoryName(INVENTORY_ANIMATION,inventory_n umber);

inventory_n umber);

needs to be:

inventory_number);

and around line line 129:

llRequestPermissions(avatar,PERMISSION_TRIGGER_ANI MATION);

to llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);

Those 2 simple, little spaces were what was keeping the script from compiling. Since your script did not save you will probably need to check the "running" box on the bottom left of the script window.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Tarina Sewell
Just Browsing Thank you
Join date: 20 Jul 2007
Posts: 2,180
10-16-2007 15:23
okay, It seems the script reads the animations. Seems to work fine but I'm still just sitting on it and it wont animate, in the pie menu I get touch and sit...

No wait!!

I took it back into inventory re rezzed it and it works!! Oh thank you sooooooooooooooooo much!!

HUG HUG HUG TY TY TY
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-16-2007 15:38
From: Tarina Sewell
okay, It seems the script reads the animations. Seems to work fine but I'm still just sitting on it and it wont animate, in the pie menu I get touch and sit...

I'll make a full mod, working copy with a handfull of animations in it and come into world later and send it your way. That way you will also be able to compare the two scripts.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-16-2007 17:01
OMG!!!! WOOT! WOOT!
About to send you a copy when I checked the forum again!

Congratulations!!!!!!!!!!!!!!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Yuo Rang
Registered User
Join date: 21 Aug 2007
Posts: 20
10-16-2007 20:40
This is great, now i can view all my 800+ freebie anims without going nuts opening them all.

However theres one thing missing - some kind of 'vend for 0 Lindens' option so I can take out the one i want without having to wait for an 800 strong content list to load.

Any ideas of a codeblock addon for that please?
Kaiyo Izutsu
Registered User
Join date: 20 Aug 2006
Posts: 28
10-23-2007 02:19
If can make the stand to rotate through channel, it'll be perfect! Anyone knows how to do it?
Phoenix Chapman
Registered User
Join date: 7 Feb 2007
Posts: 17
10-26-2007 20:27
I've been trying to get this to work, and I must suck. I get an error when I try to save the script:

(0, 0) : ERROR : Syntax error.

What's the error?
_____________________
http://belessstupid.wordpress.com
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-26-2007 20:47
From: Phoenix Chapman
I've been trying to get this to work, and I must suck. I get an error when I try to save the script:

(0, 0) : ERROR : Syntax error.

What's the error?

Did you per chance copy in the php tags by mistake?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Phoenix Chapman
Registered User
Join date: 7 Feb 2007
Posts: 17
10-26-2007 21:11
Ok, I took out the php tags (my bad :P ), but now I get the 50, 72 errors. I saw the fix on the first page for that, so I'll go fix them. Thanks so much for your help!
_____________________
http://belessstupid.wordpress.com
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
10-27-2007 09:12
When I get a little time, I'll post a script that allows you to cycle through the poses using left and right arrows (or perhaps, shift-arrow, so you can still use the arrows to rotate your view). Only one prim needed. This would be a simplification of the Easy Sit Target helper script, and you can simply use that in the meantime (find it for free on SLX).
Naiman Broome
Registered User
Join date: 4 Aug 2007
Posts: 246
10-29-2007 11:32
Hi how can I make so that the animation played is rotated to the side I want it to be played?
Jasmin Loire
Want to do my grading?
Join date: 4 Nov 2007
Posts: 68
12-13-2007 17:45
I'm getting an error message in compiling that hasn't been brought up yet:

(18, 0) : ERROR : Syntax error

The line in question:
vector animation_offset = <0,0,1.5>; // Animation offset from stand

Thanks in advance for any help you can offer.
1 2