Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need some help with a danceball

Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
06-23-2008 12:08
Hi all,

I hope someone can help me with a script i made.
What i try to build is when someone touch the danceball, the danceball check if that person is
on the list.
if NO then the person will be added to the list and start dancing and sent a short particle stream to that person.
if Yes then the person will be deleted from the list and stop dancing.

most of the script is working but there is something wrong in the stop part of the script.
If i test it with 1 person it works but with several persons sometimes the stops works and sometimes not and i can't find what i have done wrong.:(((

<CODE>
list NamesDetected;
string NewName;
string Dance;
string DanceAnim;
key AvatarKey;
integer index;

MakeParticles()
{
llParticleSystem(
[
PSYS_PART_FLAGS,
PSYS_PART_TARGET_POS_MASK |
PSYS_PART_EMISSIVE_MASK,

PSYS_SRC_TARGET_KEY, AvatarKey,
PSYS_PART_START_SCALE, <.25,.25, 0>,

PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP,

PSYS_SRC_TEXTURE, "Heart",

PSYS_SRC_BURST_SPEED_MIN, 2.0,
PSYS_SRC_BURST_SPEED_MAX, 2.0,

PSYS_PART_MAX_AGE, 3.0,
PSYS_SRC_BURST_PART_COUNT, 1,
PSYS_SRC_BURST_RATE, 0.25
]);
}


default
{
state_entry()
{
DanceAnim=llGetInventoryName(INVENTORY_ANIMATION,0);
llTargetOmega(<0,0,0.1>,2*PI,1.0);
}

touch_start(integer total_number)
{
AvatarKey= llDetectedKey(0);
NewName=llDetectedName(0);
index = llListFindList(NamesDetected, [NewName] );

if (index != -1)
{
//Found name on list
NamesDetected=llDeleteSubList(NamesDetected, index, index);
Dance="Off";
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
}
else
{
//Didn't find name on list
NamesDetected=NamesDetected +[NewName];
Dance="On";
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{

if(DanceAnim == "";)
{
DanceAnim=llGetInventoryName(INVENTORY_ANIMATION,0);
}

if(Dance=="On";)
{
llStopAnimation(DanceAnim);
llStartAnimation(DanceAnim);
llSay(0, "Welcome " + NewName);

MakeParticles();
llSetTimerEvent(1.5);
}
else
{
llStopAnimation(DanceAnim);
llSay(0, "Thanks for dancing with us " + NewName);
}
}
}

timer()
{
llParticleSystem([]);
}
}
<CODE>
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
06-23-2008 12:35
im looking at it now in world, it seams to be something in the permission at first glance or something with the way Dance is defined
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
try this,
06-23-2008 12:46
im geting a animation stop bug but it basicly works now
if you can get that animation bug fixed there you go :P
CODE

list NamesDetected;
string NewName;
string DanceAnim;
key AvatarKey;
integer index;

MakeParticles()
{
llParticleSystem(
[
PSYS_PART_FLAGS,
PSYS_PART_TARGET_POS_MASK |
PSYS_PART_EMISSIVE_MASK,

PSYS_SRC_TARGET_KEY, AvatarKey,
PSYS_PART_START_SCALE, <.25,.25, 0>,

PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP,

PSYS_SRC_TEXTURE, "Heart",

PSYS_SRC_BURST_SPEED_MIN, 2.0,
PSYS_SRC_BURST_SPEED_MAX, 2.0,

PSYS_PART_MAX_AGE, 3.0,
PSYS_SRC_BURST_PART_COUNT, 1,
PSYS_SRC_BURST_RATE, 0.25
]);
}


default
{
state_entry()
{
DanceAnim=llGetInventoryName(INVENTORY_ANIMATION,0 );
llTargetOmega(<0,0,0.1>,2*PI,1.0);
}
touch_start(integer total_number)
{
AvatarKey= llDetectedKey(0);
NewName=llDetectedName(0);
index = llListFindList(NamesDetected, [NewName] );
if (index != -1)
{
//Found name on list
NamesDetected=llDeleteSubList(NamesDetected, index, index);
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
llWhisper(0,"list");
}
else
{
//Didn't find name on list
NamesDetected=NamesDetected +[NewName];
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
llWhisper(0,"no list");
}
}
run_time_permissions(integer perm)
{
DanceAnim=llGetInventoryName(INVENTORY_ANIMATION,0 );
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStartAnimation(DanceAnim);
llSay(0, "Welcome " + NewName);
MakeParticles();
llSetTimerEvent(1.5);
}
else
{
llStopAnimation(DanceAnim);
llSay(0, "Thanks for dancing with us " + NewName);
}
}
timer()
{
llParticleSystem([]);
}
}
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
06-23-2008 13:13
Thanks for the try but now the person don't stop dancing at all :)
The stop bug was just the thing i couldn't fix.

without the dance=on switch the script always start the dance and the stop part never trigger.

But thanks i will try more maybe i can fix it :)

EDIT: I did found where the error is but don't know yet how to solve it.

The problem is if the person click the 2e time he/she will be removed from the list even if he/she clicks no on the permission reguest. if he/she then click a 3e time to stop the script don't see the person on the list and add the person again:)
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
06-24-2008 00:51
From: Kaylan Draken
EDIT: I did found where the error is but don't know yet how to solve it.

The problem is if the person click the 2e time he/she will be removed from the list even if he/she clicks no on the permission reguest. if he/she then click a 3e time to stop the script don't see the person on the list and add the person again:)

The real problem is that each script can only remember permissions for one avatar at a time. There are two ways you can fix this.

The first way, if you only want to use one script, is to compare llGetPermissionsKey() against your llDetectedKey(). If it is _not_ the same, or if permissions have not been granted, you need to request permissions again. You will need to check both of these each time you start or stop an animation.

The second way is to use helper scripts, this will let you ask for permissions only once. You would assign a helper script to each avatar who is dancing, and use link messages to tell the helper to start and stop animations. The helper would keep track of that avatar's permissions, and release itself if the avatar goes away. This does give a better user experience, but you do gain the extra load of running extra scripts, and the number of avatars who can dance is limited by the number of helpers.

You might look in the scripting library here for the solop scripts, they already do all this.

ed: here: /15/28/26552/1.html
_____________________