Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

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
Discussion Thread
08-18-2006 20:53
/54/56/131078/1.html
_____________________
i've got nothing. ;)