Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can someone help with this bit of code?

Rock Vacirca
riches to rags
Join date: 18 Oct 2006
Posts: 1,093
10-14-2008 14:26
Hi,

I am trying to build my own menu-driven basic dance machine. The menu is all set up, the key of the person who touches the prim with the script in goes into the key variable, dancer, and when I select the first dance on the menu, the listen handler handles the selection like this:

CODE


if (message == d1)
{
llRequestPermissions(dancer, PERMISSION_TRIGGER_ANIMATION); //(a)
integer perm = llGetPermissions();//(b)
curAnim = d1;//(c)
llStartAnimation("Club Dance1"); //(d)
llSay(0, "The permission is " + (string)perm);//(e)

}

[\CODE]

I have two questions:

1. Why does the (e) llSay happen BEFORE the Yes button has been pressed to grant permission for my avatar to be animated? (a)

2. When I do select Yes for my avatar to be animated, the Start animation (d) does not work. Can anyone tell me why?

TIA

Rock
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
10-14-2008 14:45
What you want, I think, is more like this:
CODE


if (message == d1)
{
llRequestPermissions(dancer, PERMISSION_TRIGGER_ANIMATION);
curAnim = d1;
}

run_time_permissions(integer perm)
{
llStartAnimation("Club Dance1");
llSay(0, "The permission is " + (string)perm);
}

[\CODE]

See, the user clicking "yes" is what actually grants the permissions and this fires the run_time_permissions event. So I've created an event handler and the code inside it waits for the permissions to be granted before running.

The way you had it, everything just happens one after the other; there was no code waiting for the perms to come through (clicking "yes").

Hope that helps some.
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously. ;)

http://slurl.com/secondlife/Brownlee/203/110/109/

Rock Vacirca
riches to rags
Join date: 18 Oct 2006
Posts: 1,093
10-14-2008 16:32
Thanks very much Anti.

Very logical the way you explained it.

Rock
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-14-2008 17:11
if i may add, add a else part to the menu so peaple can stop the animation without having to use the stop all animations button

CODE

run_time_permissions(integer perm)
{
if(perm)
{
llStartAnimation("Club Dance1");
llSay(0, "The permission is " + (string)perm);
}
else if(!perm) // perm == false
{
llStopAnimation("Club Dance1");
}
}


it should work to lazy atm to test it inworld, if you chose no to the animation it should stop it if it is already running