Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Multiple Anim

Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
08-17-2006 22:00
Here is a script that I did a long time ago for making a posing stand that supported multiple poses/anims. The pose is selected with a dialog. The pose can be changed while you are sitting.

CODE

// written by Norman Desmoulins
// Multiple Sit w/Dialog

vector sitPosition = <0.0, 0.0, 0.73>;
string sitText = "";
string sitAnim = "";
integer sitAnimIndex;

integer showAnim;
integer listenHandle = 0;
integer listenChannel;

hidePoseBall()
{
showAnim = FALSE;
llSetAlpha(0.0, ALL_SIDES);
llSetText(" ", <0,0,0>,0.0);
}

showPoseBall()
{
showAnim = TRUE;
llSetAlpha(1.0, ALL_SIDES);
llSetText(sitText, <1,1,1> , 1);
}

getText()
{
sitAnim = llGetInventoryName(INVENTORY_ANIMATION,sitAnimIndex);
sitText = llGetObjectDesc();
if ((llStringLength(sitText)==0) || (sitText=="(No Description)"))
sitText = sitAnim;
}

default
{
state_entry()
{
listenChannel = (integer)(llFrand(1.0) * 10000.0 + 1000.0);
if (listenHandle != 0)
llListenRemove(listenHandle);
listenHandle = llListen(listenChannel, "", NULL_KEY, "");

getText();
llSetSitText(sitText);
llSitTarget(sitPosition, ZERO_ROTATION);
llSetText(sitText, <1,1,1> , 1);
}

touch_start(integer changes)
{
list poseList;
integer j;
integer i;
j = llGetInventoryNumber(INVENTORY_ANIMATION);
for (i = 0; i < j; i++)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
poseList = poseList + [name];
}
llDialog(llDetectedKey(0), "Select pose", poseList, listenChannel);
}

listen(integer c, string n, key id, string m)
{
sitAnimIndex = 0;
integer j;
integer i;
j = llGetInventoryNumber(INVENTORY_ANIMATION);
for (i = 0; i < j; i++)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
if (name==m)
{
sitAnimIndex = i;
i = j;
}
}

sitText = m;
if (showAnim)
{
llSetText(sitText, <1,1,1> , 1);
}
else
{
integer perm = llGetPermissions();
if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(sitAnim)>0)
{
llStopAnimation(sitAnim);
llStartAnimation(m);
}
}
sitAnim = m;
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
integer perm = llGetPermissions();
if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(sitAnim)>0)
llStopAnimation(sitAnim);
showPoseBall();
}
}
else if (change & CHANGED_INVENTORY) llResetScript();
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
getText();
llStartAnimation(sitAnim);
hidePoseBall();
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
08-18-2006 20:53
/15/88/130852/1.html
_____________________
i've got nothing. ;)
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
08-18-2006 21:31
From: Norman Desmoulins
CODE

j = llGetInventoryNumber(INVENTORY_ANIMATION);

If there's more than 12 animations in the object inventory it'll go belly up when dialog function is called ... some kind of simplest check would be probably a good idea ^^;
CODE

if( j > 12 ) { j = 12; }

after the quoted line, or something... there's also potential issue with animation names longer than 24 characters ^^;
Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
08-18-2006 22:21
Sure... it's up to you to decide which is the worse of two evils... arbitrarily leaving out anims from the dialog, or no dialog showing up.
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
08-22-2006 14:57
If I am sitting using this script and I teleport away without standing up then I continue to sit at my destination. I guess my AV is gone before the llStopAnimation is called. Is there any way around this?
HtF Visconti
Registered User
Join date: 21 Jul 2006
Posts: 123
08-23-2006 02:10
With more than 12 anims it is usually a good idea to make a new menu page - having one "MORE" button on the first page that will present the next dialogue.

You could also limit the amount of animations dropped in the inventory by checking how many anims are in it already and writing out an error message when the limit is reached.

Better safe than sorry - or be prepared to be IM'ed by new users with questions like "Where did my 13th animation go?" :)
LadyMacbrat Loveless
Registered User
Join date: 15 Oct 2004
Posts: 211
01-29-2007 13:32
From: HtF Visconti
With more than 12 anims it is usually a good idea to make a new menu page - having one "MORE" button on the first page that will present the next dialogue.

You could also limit the amount of animations dropped in the inventory by checking how many anims are in it already and writing out an error message when the limit is reached.

Better safe than sorry - or be prepared to be IM'ed by new users with questions like "Where did my 13th animation go?" :)



And how is this done with having the menu get the list of more than 12 animations?
thanks
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
01-29-2007 17:52
If I understand what you are asking, you make a list with 11 animations and "more". Then, if a user selects "more", you reload a list with items 12-22 and present a menu with "those" items. In other words, in the listen event, if message == "more", call llDialog with a new list. There are probably a number of different ways of populating this second list.

Baron H.
LadyMacbrat Loveless
Registered User
Join date: 15 Oct 2004
Posts: 211
01-30-2007 08:43
From: Baron Hauptmann
If I understand what you are asking, you make a list with 11 animations and "more". Then, if a user selects "more", you reload a list with items 12-22 and present a menu with "those" items. In other words, in the listen event, if message == "more", call llDialog with a new list. There are probably a number of different ways of populating this second list.

Baron H.


Norman's script above works great except for the 12 anim limit. I was trying to use that script allowing for the additional menu items. Thanks for such a quick response, Baron.