Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

What do i wrong?

Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
11-14-2007 11:32
Hi all,

I am trying to make a danceball but have trouble with removing a name from the list.
I am looking several hours on this part but can't see what i am doing wrong.
with the first click the person is added to the list with the second click that person has to be removed from the list. But now the wrong person stops dancing :(

<code>
//this part is in a touch event.
NewName=llDetectedName(0);
index = llListFindList(NamesDetected, [NewName] );

if (index != -1)
{
NamesDetected=llDeleteSubList(NamesDetected, index, index);
llStopAnimation(DanceAnim);
llSay(0, "Thanks for dancing with us " + NewName);
}
else
{
NamesDetected=NamesDetected +[NewName];
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
}

<code>
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-14-2007 16:05
The script can only handle permissions for one avatar at a time.

I suppose that your test involves an avatar clicking to start dancing... then, a second avatar clicks to start dancing. At that point, the script acquires permission from Avatar#2 and forgets about Avatar#1. So, when Avatar#1 clicks again to stop dancing... the function llStopAnimation() acts on Avatar#2, for which it has permissions... rather than Avatar#1.

One option is to use one script per expected dancer. You can dynamically add scripts as need, and remove them later but that can get complex. Or, you could include 20 scripts in your dance ball, therefore supporting 20 dancers at once.
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
11-15-2007 11:14
hi DoteDote,

My intension was :
1- when avatar touch the danceball, Look if avatars name is on the list (NamesDetected)
2- if answer is no (index =0), add the name to the list and ask PERMISSION to animate
3- if answer is yes (index !=0), remove the avatar name from list and stop the anmiation for that avatar.

if a second avatar click on the danceball he/she goes to the step above again.

i don't know if what i want is possible it looks like the last detected name is stopped and
not the avatar who is clicking on the danceball.

EDIT:
i have solved it i have to ask permisions when i start en when i stop.

i have a question about this is it possible to store/save the permissionkey in the list so that
i don't have to ask for permission when i stop?
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-15-2007 15:56
From: Kaylan Draken
i have a question about this is it possible to store/save the permissionkey in the list so that
i don't have to ask for permission when i stop?
No. From lslwiki.net :

From: someone
Further, multiple agents may not grant permissions to the same script at the same time. For an object to have permissions for multiple agents simultaneously, one script is needed for each agent. They may still be within the same prim, however.

It may be best to use a single script to handle your list, and farm the animation control to separate scripts in the same object. Communicate between the scripts using llMessageLinked().

http://lslwiki.net/lslwiki/wakka.php?wakka=llRequestPermissions
http://lslwiki.net/lslwiki/wakka.php?wakka=llMessageLinked
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
11-15-2007 23:28
Thanks DoteDote for your answer i will look at it.

a pity i can't store permisionsKey would be handy.