Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Poseball doesnt ask for animation permissions from new AV.. why?

Erluen Twin
Registered User
Join date: 26 May 2006
Posts: 23
01-06-2009 23:59
Im making a dance with 2 poseballs that are synchronized.

The problem is, they only ask for permissions from the first couple to use them, and never again. When a new couple sits, it says either "ERROR, AGENT NOT FOUND" (meaning the first AV who sat on it is not online)
or
it says "Sorry, you must give permissions".
I coded that phrase in for when an AV does not give permissions, but it didn't even ask!! It SEEMS to think that since it got permissions once, it doesnt have to ask again.. something to do with the "ELSE //got perms already so continue " statement. Look for the ********************

what code do I need to add/delete to make it ask for perms from ANY Avatar that sits?

Background info...
I found this script on these forums somewhere for synched animations. I added what I needed to and change some things slightly, but not the permissions. It appeared to work beautifully until I tried swapping the Avatars. Then, strangely, the Female would still do the female dance, even while on the male poseball, and vice versa. And as I mentioned, if a new AV gets on, permissions are not asked for, and the AV will not dance.

Keywords: perms perm trigger animation llGet Permissions
!= NULL_KEY

(ps... !! how can I search for answers when this forum doesnt allow me to search for PERMISSION_TRIGGER_ANIMATION because its too long? !!)

Here is the code...
CODE


// Global variables to keep track of my partner's state
integer sittingOnPartner = 0; // Default state, we begin with no one sitting
vector POS = <0.3, 0.0, 0.1>;
// Same thing for my own state
integer sittingOnMe = 0; // Default state, we begin with no one sitting

integer hidden = FALSE;
integer linkhide = FALSE;
string BALLTEXT = "sit";
vector TEXTCOLOR = <1,1,1>;
string anim = "dance manO2";

hide() {
llSetText("", <1,1,1>, 1);
llSetAlpha(0, ALL_SIDES);
hidden = TRUE;
}



show() {
llSetText(BALLTEXT, TEXTCOLOR, 1);
llSetAlpha(1, ALL_SIDES);
hidden = FALSE;
}


// Function to tell partner my state
tellPartner(integer myState)
{
llMessageLinked(LINK_ALL_OTHERS, myState, "", NULL_KEY);
}

default {
state_entry() {
llSitTarget(POS, ZERO_ROTATION);
show();
}

changed(integer change) { //someone sits or gets off the ball
if (change == CHANGED_LINK) {
key avatar = llAvatarOnSitTarget();

if (avatar != NULL_KEY) {
integer perms = llGetPermissions();
if (!(perms & PERMISSION_TRIGGER_ANIMATION)) {
// No perms, need to request them
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
hide();
}
//*********************************** SOMETHING IS WRONG HERE MAYBE****************************

else {
hide();
// We have perms, so do what we need to do
integer perm = llGetPermissions();
if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(anim) > 0) {
llStopAnimation(anim);

}

// Someone just sat down on me. First, set my own variable****************************************
sittingOnMe = 1;

// Tell my partner that someone's sitting on me, so he
// can check if someone's sitting on him and start his
// animation
tellPartner(1);

// See if partner has already told me that someone's sitting
// on him. If he has, then this person is the 2nd person to
// sit, and I need to start my animation. If not, then this
// person is the 1st person to sit, and I need to wait until
// someone sits on my partner and he lets me know via a link
// message and then start my animation
if (sittingOnPartner == 1)
{
llSleep(0.6);
llStartAnimation((string)anim);
}

}}
else
{
show();
// My person got off. No need to stop animation, because his
// animation would have stopped automatically. But I do need
// to let my partner know, so if there's still someone on his
// ball, he can stop his animation.

// First set my own state
sittingOnMe = 0;

// Now tell partner
tellPartner(0);
}
}
}

// Run time permissions - basically a repeat of what we did when we detected an
// avatar had sat down and we have the perms
run_time_permissions(integer perms) {
if (!(perms & PERMISSION_TRIGGER_ANIMATION)) {
llWhisper(0,"You must give permission");
}
else {
// A copy of the code from the block inside the change handler above

// Someone's just sat down on me. First, set my own variable
sittingOnMe = 1;

// Tell my partner that someone's sitting on me, so he
// can check if someone's sitting on him and start his
// animation
tellPartner(1);

// See if partner has already told me that someone's sitting
// on him. If he has, then this person is the 2nd person to
// sit, and I need to start the animation. If not, then this
// person is the 1st person to sit, and I need to wait until
// someone sits on my partner and he lets me know via a link
// message
if (sittingOnPartner == 1)
{
llStopAnimation("sit");
llSleep(0.6);
llStartAnimation(anim);

}

}
}

// Now for the link message handler, i.e. when stuff happens in the other ball
link_message(integer sender, integer num, string str, key id) {
if (num == 1) {
sittingOnPartner = 1;// Partner is telling us someone sat on him. Remember that

// Do we have someone already sitting on us? If yes, then this is the
// 2nd person to sit down, and we need to start the animation
if (sittingOnMe == 1)
{
llSleep(0.6); // this is to synch the dance more correctly. The animation was a bit off at the beginning.
llStartAnimation(anim);
}

// Else... nothing to do. Whoever sat on the other ball is the first sitter.
// When someone sits on me, I'll get the change event, I'll detect that the
// partner already has someone sitting, and I'll start the animation there
}
else
{
// Someone got off partner
sittingOnPartner = 0;

// Is someone still sitting on me? If so, I need to stop his animation
if (sittingOnMe == 1)
{
llStopAnimation(anim);
}

}
}
}

Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-07-2009 00:55
try...

if (llGetPermissionsKey() != avatar) {
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
}
...in your changed event

edit/explanation -- you are only checking whether you have the animation permissions but not for who!

/esc
_____________________
http://slurl.com/secondlife/Together
Erluen Twin
Registered User
Join date: 26 May 2006
Posts: 23
01-07-2009 01:19
Hmm thank you. I tried that by adding it directly after
hide();
}
else {
hide();
in my changed event. Worked like a charm!!!
Even solved the swapping issue!
:)