Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can't find animation error

Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
06-03-2006 21:08
I am using a dialog menu to select animation. The menu is generated by the scritp reading the anmatons for contents. So I know that it is correct, but when an animation is selected an error flag pops up follow quicky by the playing of the animation is says it cannot find. If is cannot find it how does it play it.

<CODE>
float time = 30;

integer channel = -1; //Initial communication channel
integer perm; //Permission to animate AV
integer totalAnima; // Total number of animations

list animaList; // List of animations
list main_menu;
list menu1;
list menu2;
list menu3;
integer next;
integer back;

string animaName; // Name of the current animation
string animaNew; // Name of next animation

init()
{

if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0)//Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.";);
animaNew = "sit";
}
else
{
totalAnima = llGetInventoryNumber(INVENTORY_ANIMATION);
// llOwnerSay((string) totalAnima + "*";);
animaList = [];
integer i;
for(i=0;i< totalAnima; i++)
{
animaList=animaList+llGetInventoryName(INVENTORY_ANIMATION,i);
}
if(totalAnima <= 11)
{
//llOwnerSay((string)llGetListLength(animaList));
//llOwnerSay((string) totalAnima);
//llOwnerSay("menu1";);
menu1 = llList2List(animaList,0,-1);
menu1 = menu1 + ["Main"];
menu2 = [];
menu3 = [];
}
if(totalAnima > 11 & totalAnima <= 18)
{
//llOwnerSay("menu2";);
menu1 = llList2List(animaList,0,8);
menu1 = menu1 + ["Next","Back","Main"];
menu2 = llList2List(animaList,9,-1);
menu2 = menu2 + ["Back","Main"];
menu3 = [];
}
if(totalAnima > 18)
{
//llOwnerSay("menu3";);
menu1 = llList2List(animaList,0,8);
menu1 = menu1 + ["Next","Back","Main"];
//llOwnerSay((string)llGetListLength(menu1));
menu2 = llList2List(animaList,9,17);
menu2 = menu2 + ["Next","Back","Main"];
//llOwnerSay((string)llGetListLength(menu2));
menu3 = llList2List(animaList,22,-1);
menu3 = menu3 + ["Back","Main"];
//llOwnerSay((string)llGetListLength(menu3));
}
if(totalAnima > 28)
{
llOwnerSay("Only the first " + llGetObjectName() + " are available!";);
}
}
}
avActions()
{
if(animaNew !="";)
{
llStopAnimation(animaName);
llSleep(0.5);
}
llOwnerSay(animaNew);
llStartAnimation(animaNew);
animaName = animaNew;
}

default
{
on_rez(integer prim_params)
{
llResetScript();
}

state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH);
llListen(channel, "", llGetOwner(), "";);
init();
}

listen(integer channel, string name, key id, string message)
{
//llOwnerSay(name + " " + message);
if(id == llGetOwner())
{
llStopAnimation(llGetAnimation(llGetOwner()));
message = (string) message;
//llOwnerSay("M "+message);
integer index = llListFindList(animaList, [message]);
//llOwnerSay("Index " + (string)index);
if(index != -1)
{
llStopAnimation(llGetAnimation(llGetOwner()));
animaNew = llList2String(animaList, index);
llOwnerSay(animaNew);
//ll(llGetOwner(), "1Choose Animation", menu1, channel);
next = 0;
llSetTimerEvent(10); ///8888888888888888888
avActions();
return;
}
if(message == "Next";)
{
next = next + 1;
if( next == 1)
{
llStopAnimation(llGetAnimation(llGetOwner()));
llDialog(llGetOwner(), "Choose Animation", menu2, channel);
return;
}
if( next == 2)
{
llDialog(llGetOwner(),"Choose Animation",menu3,channel);
return;
}
}
if(message == "Back";)
{
llDialog(llGetOwner(),"Choose Animation", menu1, channel);
return;
}
if( message == "Main";)
{
llMessageLinked(LINK_SET,0,llToUpper(message),NULL_KEY);
}
}
}

changed(integer change)
{
if(change == CHANGED_INVENTORY)
{
llOwnerSay("Script Reset";);
init();
}
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_ATTACH)
{
llAttachToAvatar(ATTACH_LHIP);
}
}
attach(key attached)
{
if (attached != NULL_KEY) // object has been //attached//
{
llSetTimerEvent(time);
}
else // object has been detached
{
if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animaNew);
llSetTimerEvent(0.0);
}
}
}
link_message(integer sender_number,integer num,string str, key id)
{

if(sender_number == 1)
if(str == llGetLinkName(llGetLinkNumber()))
{
llDialog(llGetOwner(),"Choose Animation", menu1, channel);
}
}
timer()
{
llStopAnimation(animaName);
}
}
</CODE>
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
06-03-2006 22:00
Hi!

You have your CODEs enclosed in angle brackets, <>. They should be enclosed in square brackets, [].

Also, I think people prefer the result of the PHP and /PHP, for some reason.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
06-03-2006 23:56
CODE

integer totalAnima; // Total number of animations

list animaList; // List of animations
//...
string animaName; // Name of the current animation
string animaNew; // Name of next animation


Consider writing better and more descriptive variable names, that way you don't need to write comments explaining what they actually do.

CODE

avActions()
{
if(animaNew !="")
{
llStopAnimation(animaName);
llSleep(0.5);
}
llOwnerSay(animaNew);
llStartAnimation(animaNew);
animaName = animaNew;
}


You don't need a llSleep in there.

CODE

on_rez(integer prim_params)
{
llResetScript();
}

You don't need a llResetScript here.

CODE

state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH);
llListen(channel, "", llGetOwner(), "");
init();
}


You should put the listen in the run_time_permissions event handler.

CODE

listen(integer channel, string name, key id, string message)
{
//llOwnerSay(name + " " + message);
if(id == llGetOwner())
{
llStopAnimation(llGetAnimation(llGetOwner()));

This is incorrect. The function you're wanting is llGetAnimationList to get the list of animations currently playing on the avatar.

CODE


llStopAnimation(llGetAnimation(llGetOwner()));

Same problem as above.

CODE

llSetTimerEvent(10); ///8888888888888888888

Why write a meaningless comment? Are you paid by quantity of code?

CODE

llStopAnimation(llGetAnimation(llGetOwner()));
llDialog(llGetOwner(), "Choose Animation", menu2, channel);
return;

Same problem again.


CODE

changed(integer change)
{
if(change == CHANGED_INVENTORY)
{
llOwnerSay("Script Reset");
init();
}
}

Why do you tell the owner that the script has been reset, when it's NOT reset?
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Thanks
06-04-2006 02:48
While I appreciate your attempt to help me writing better code. I should had said that several things were the to try to track down problems and will be removed later. However. I do not see anyting that you have said explains the error code.
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
06-04-2006 05:00
CODE

float time = 30;

integer channel = -1; //Initial communication channel
integer perm; //Permission to animate AV
integer totalAnima; // Total number of animations

list animaList; // List of animations
list main_menu;
list menu1;
list menu2;
list menu3;
integer next;
integer back;

string animaName; // Name of the current animation
string animaNew; // Name of next animation

init()
{

if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0)//Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.");
animaNew = "sit";
}
else
{
totalAnima = llGetInventoryNumber(INVENTORY_ANIMATION);
// llOwnerSay((string) totalAnima + "*");
animaList = [];
integer i;
for(i=0;i< totalAnima; i++)
{
animaList=animaList+llGetInventoryName(INVENTORY_ANIMATION,i);
}
if(totalAnima <= 11)
{
//llOwnerSay((string)llGetListLength(animaList));
//llOwnerSay((string) totalAnima);
//llOwnerSay("menu1");
menu1 = llList2List(animaList,0,-1);
menu1 = menu1 + ["Main"];
menu2 = [];
menu3 = [];
}
if(totalAnima > 11 & totalAnima <= 18)
{
//llOwnerSay("menu2");
menu1 = llList2List(animaList,0,8);
menu1 = menu1 + ["Next","Back","Main"];
menu2 = llList2List(animaList,9,-1);
menu2 = menu2 + ["Back","Main"];
menu3 = [];
}
if(totalAnima > 18)
{
//llOwnerSay("menu3");
menu1 = llList2List(animaList,0,8);
menu1 = menu1 + ["Next","Back","Main"];
//llOwnerSay((string)llGetListLength(menu1));
menu2 = llList2List(animaList,9,17);
menu2 = menu2 + ["Next","Back","Main"];
//llOwnerSay((string)llGetListLength(menu2));
menu3 = llList2List(animaList,22,-1);
menu3 = menu3 + ["Back","Main"];
//llOwnerSay((string)llGetListLength(menu3));
}
if(totalAnima > 28)
{
llOwnerSay("Only the first " + llGetObjectName() + " are available!");
}
}
}
avActions()
{
if(animaNew !="")
{
llStopAnimation(animaName);
llSleep(0.5);
}
llOwnerSay(animaNew);
llStartAnimation(animaNew);
animaName = animaNew;
}

default
{
on_rez(integer prim_params)
{
llResetScript();
}

state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH);
llListen(channel, "", llGetOwner(), "");
init();
}

listen(integer channel, string name, key id, string message)
{
//llOwnerSay(name + " " + message);
if(id == llGetOwner())
{
llStopAnimation(llGetAnimation(llGetOwner()));
message = (string) message;
//llOwnerSay("M "+message);
integer index = llListFindList(animaList, [message]);
//llOwnerSay("Index " + (string)index);
if(index != -1)
{
llStopAnimation(llGetAnimation(llGetOwner()));
animaNew = llList2String(animaList, index);
llOwnerSay(animaNew);
//ll(llGetOwner(), "1Choose Animation", menu1, channel);
next = 0;
llSetTimerEvent(10); ///8888888888888888888
avActions();
return;
}
if(message == "Next")
{
next = next + 1;
if( next == 1)
{
llStopAnimation(llGetAnimation(llGetOwner()));
llDialog(llGetOwner(), "Choose Animation", menu2, channel);
return;
}
if( next == 2)
{
llDialog(llGetOwner(),"Choose Animation",menu3,channel);
return;
}
}
if(message == "Back")
{
llDialog(llGetOwner(),"Choose Animation", menu1, channel);
return;
}
if( message == "Main")
{
llMessageLinked(LINK_SET,0,llToUpper(message),NULL_KEY);
}
}
}

changed(integer change)
{
if(change == CHANGED_INVENTORY)
{
llOwnerSay("Script Reset");
init();
}
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_ATTACH)
{
llAttachToAvatar(ATTACH_LHIP);
}
}
attach(key attached)
{
if (attached != NULL_KEY) // object has been //attached//
{
llSetTimerEvent(time);
}
else // object has been detached
{
if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animaNew);
llSetTimerEvent(0.0);
}
}
}
link_message(integer sender_number,integer num,string str, key id)
{

if(sender_number == 1)
if(str == llGetLinkName(llGetLinkNumber()))
{
llDialog(llGetOwner(),"Choose Animation", menu1, channel);
}
}
timer()
{
llStopAnimation(animaName);
}
}

If you want to get people look at your code in the forums here, you would do well to use the correct vBulletin codes, as I explained in my previous post. Doing so will preserve the indentation and make the code be syntax colored, thus making things easier on the people you are wanting to get help from.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-04-2006 05:47
I'd try to add a check that you've got permission to animate before you call the animation. So in the avAnim() function if(perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation(...

I have absolutely NO idea why this works and your method doesn't, but it does appear to make a difference sometimes.

The other way to do it would be to restructure that so it asks for the attach permission on rez, and the permission to animate in the avAnim() function (since it's already attached it doesn't need that any more, and it shouldn't fall off) then trigger the anim in the run_time_permissions you get triggered this way...

That said if you've just tped I've had a similar error from an animator. Since it seems to be related to tping I've always blamed the asshat server for not having loaded the anims yet, maybe that's what's affecting you?
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
06-04-2006 09:14
As Angela pointed out, llStopAnimation(llGetAnimation(llGetOwner())); is what's causing the error. If you're trying to stop all animations, use llGetAnimationList, which returns a list of all anims playing, then step through the list stopping each one.
_____________________
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
06-04-2006 19:19
For that matter, llGetAnimation doesn't get your animation's name but state. It is used by triggers to play your animation. To play or stop animation, you need the name or key of the animation.
_____________________
:) Seagel Neville :)
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Thanks
06-04-2006 20:51
That as helpful information. Sorry about the formating, just for got how to do it. Anyway got it working with your help.

Mod