Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Stopping an animation w/out affecting others

Silence Monday
Registered User
Join date: 17 May 2009
Posts: 4
05-17-2009 21:43
I made a little hud that has some tiny dances in it (from BenjaKepler's tutorial on youtube). It's works really well for what I want.

At this moment, the only way I know to stop whatever dance it's running is to click the "stop all animations" in the sl client menu.

But then the tiny avatar "bounces up". Slightly annoying.

I'd like to add a way to stop whatever dance is running without messing up the tiny animation. Suggestions, please. :)

Thank you.
Moon Corrigible
Registered User
Join date: 19 Jan 2007
Posts: 75
05-17-2009 22:24
It *should* work to use llStopAnimation("the dance you dont want";);

But not actually knowing the script you are referring to I cant honestly say for certain - sorry.
Silence Monday
Registered User
Join date: 17 May 2009
Posts: 4
05-17-2009 22:49
Sorry, I was in a hurry, and forget to add the script.

Here it is:

// start script

list dances = ["dance 1","dance 2","dance 3","dance 4","dance 5",];

string dance_chosen;
key avatar;

default
{
state_entry()
{
}

touch_start(integer total_number)
{
avatar = llDetectedKey(0);
llDialog(avatar, "Choose a Dance",dances,11);

llListen(11,"",NULL_KEY,"";);

}
listen(integer channel, string name, key id, string message)
{
dance_chosen = message;
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
run_time_permissions(integer perm)
{
if(PERMISSION_TRIGGER_ANIMATION & perm)
{
llStartAnimation(dance_chosen);
}
}
}

// end script



It works just fine. I made a little box, added the script and dances in the contents, wear it as a hud. Click the hud, the blue menu appears, click a dance, give permission, start dancing. Click the hud again, pick another dance, and so on.

But not sure how to do the stop part. As I mentioned, clicking stop all animations in the client seems so crude, plus my poor little tiny does that sad little bounce up, all stretched out.

I'd like to have a dialog choice that stop whatever dance it's running, leaving all other animations alone, but being really new to scripting not sure how to go about it.
Moon Corrigible
Registered User
Join date: 19 Jan 2007
Posts: 75
05-17-2009 23:27
OK Lets try this again!

list dances = ["dance 1","dance 2","dance 3","dance 4","dance 5"];

list current_dances = []; //This will be a list of all the dances currently playing

list select_menu = ["Start Dance", "Stop Dance"]; //This will let you choose wheter to start or stop a dance I just put it here to make it easier if you want to change the terminology

string dance_chosen;
key avatar;

integer channel; //This is the channel you will talk to the HUD on

integer listener; //This will tell us whether or not the hud is currently listenting - it just cuts down on lag
float listening_time = 300; //This is the amount of seconds the listener will remain active before timing out to cut down on lag - 300 is 5 minutes.

default
{
state_entry()
{
channel = llFloor(llFrand(999)) + 100; //This gives you a random number from 100 to 1099 - the llFrand gives you a random decimal and the llFloor makes it into an integer
}

touch_start(integer total_number)
{
avatar = llDetectedKey(0);
llDialog(avatar, "Would you like to stop a dance or start a dance?", select_menu, channel); //Now here I changed the channel you were talking on from 11 to channel - this is so that you can have different dance boxes talking on different channels - really only appropriate if you have them out for multiple people to use but force of habit on my part *grin*

if(listener == FALSE)
{
listener = llListen(channel,"",NULL_KEY,"";); //Again I changed the channel from 11 to channel
}

llSetTimerEvent(listening_time); //This restarts the listener for a full five mintues every time you touch the hud.
}
listen(integer channel, string name, key id, string message)
{

if(message == "Start Dance";)
{
llDialog(avatar, "Which dance would you like to start?", dances, channel);
}
else if(message == "Stop Dance";)
{
llDialog(avatar, "Which dance would you like to stop?", current_dances, channel);
}

//Now here we start living on the edge! *grin* Basically there are only two choices for each dance. Either you ARE doing them or you ARENT. So what we are going to do is figure out which list the dance is in, and then react appropriately and not worry about keeping track of which is which. Others may well script this differently and better but this is the way I do it *grin*

else if(llListFindList(dances, [message]) != -1)
{
dance_chosen = message;
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
current_dances = current_dances + [message];

integer marker = llListFindList(dances, [message]);
llDeleteSubList(dances, marker, marker);
}

//This said - if you CAN find what we've asked for in the list of dances (that is, its position in the list is NOT -1), then we obviously arent doing it so you obviously want to start it.. so we'll start dancing, add it to the list of dances and take it off of the list of available dances. Now here's the thing.. if you are setting this out for multiple people to use and not using this as a hud this is not the best idea because it makes the dance unavailable for the next person coming along. Yes I did just think of that while I was scripting this. Ahh the joys of fluid scripting!!

else if(llListFindList(current_dances, [message]) != -1)
{
dances = dances + [message];

if(llGetPermissions() == PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation(message);
}

integer marker = llListFindList(current_dances, [message]);
llDeleteSubList(current_dances, marker, marker);
}

//This says if, instead we find the dance mentioned on the list of dances being done, then we put it back on the list of available dances, check to make sure that we have permission (I know, I know but you'd be surprised how many times that can come back to bite you in the posterior!) stop the dance and take it off of the list of dances currying boogeying on down.
}


run_time_permissions(integer perm)
{
if(PERMISSION_TRIGGER_ANIMATION & perm)
{
llStartAnimation(dance_chosen);
}
}

timer()
{
llListenRemove(listener);
llSetTimerEvent(0);

//If you havent changed anything for five mintues the listener will assume you are quite happy and quit listening until you touch it again.
}
}
Silence Monday
Registered User
Join date: 17 May 2009
Posts: 4
05-18-2009 01:04
That is SO amazing! I'm boggled at what you've added. It looks so cool. :)

I have to go to sleep (darn that need to rest), but I can't wait to play with this tomorrow. Thank you. :D
Silence Monday
Registered User
Join date: 17 May 2009
Posts: 4
05-18-2009 02:54
So, of course, I couldn't get to sleep thinking about want you wrote in the script (love the comments/explainations of your additions). :)

Tried it out. Found one tiny thing needed tweaking.

Changed: llDeleteSubList(dances, marker, marker);
To: dances = llDeleteSubList(dances, marker, marker);

Changed: llDeleteSubList(current_dances, marker, marker);
To: current_dances = llDeleteSubList(current_dances, marker, marker);

And it works perfectly. :D

It does exactly what I hoped for. The tiny no longer pops up when a dance is stopped.

I've learned quite a bit in looking up the functions and events you used in adding the stop animations to this script.

(now to get some sleep in what's left of the night!)

Thank you so much for your help.
Rygel Ryba
Registered User
Join date: 12 Feb 2008
Posts: 254
05-18-2009 03:11
This is why SL is great. I love seeing people sharing info and tips on how to do things. I had popped into this thread to see what I could do to help -but I see it's covered nicely already. :) This is a great script and I think a lot of people will find it useful.