Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Stopping Attachment Anim

Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
02-11-2009 14:58
Okay, I'm not a scripter, but after much research I have gotten this far:

CODE


default
{
state_entry()
{
llListen(15,"",llGetOwner(),"");
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
listen(integer channel, string name, key id, string message)
{
if (message == "Time")
{llStartAnimation("Pocket watch");

if (message == "Pocket")
{llStopAnimation("Pocket watch");



}
}
}
}


The problem, of course, is that the animation is not stopping when I tell it to. Otherwise it works just dandy, and only starts when I tell it to, rather than when the object is attached. Would someone please tell me what I am missing regarding stopping it?

Must I tell it to start another animation to get rid of the old one?
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
02-11-2009 15:08
The problem is your braces (the squiggly brackets). Whenever you have an "if" followed by an opening brace "{", you have to make sure to put in a corresponding closing brace "}" immediately after the commands you want it to execute. You've put all your closing braces right at the end of the listen event, so what you've actually done is contained the "Pocket" command inside the "Time" command, so it can effectively never work.

Anyway, long-story short, this should be the fixed script:

CODE

default
{

state_entry()
{
llListen(15,"",llGetOwner(),"");
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

listen(integer channel, string name, key id, string message)
{
if (message == "Time")
{
llStartAnimation("Pocket watch");
}

if (message == "Pocket")
{
llStopAnimation("Pocket watch");
}
}

}
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
02-11-2009 15:31
Hey-hey! It works! Thanks SOOO much. :)