Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

poseball roadblock

Domneth Dingson
Registered User
Join date: 20 Nov 2006
Posts: 126
01-01-2007 10:22
Again, I appreciate a bit of help with this. I know others have created nice ones, but I'm in the process of learning LSL-and overcoming these various obstacles are important to my learning process. I've seen some other people's work, but they're mostly poseballs with a million options(too confusing for me at this point) and I just want one simple thing from mine..


I've gotten it to disappear on sit so it's not in the view, but I'm having a hard time getting it to reappear on standing back up. ^^

Anyways, the following is incorrect, but I thought posting it might give someone an idea of what I'm trying to do and the proper (hopefully simplest) way to accomplish this.


CODE

integer hidden = FALSE;

default
{
state_entry()
{
llSitTarget(<0,0,.1>, ZERO_ROTATION);
llSetSitText("Pose!");
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
key avataronsittarget = llAvatarOnSitTarget();
if( avataronsittarget != NULL_KEY )
{
if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget)
{
llStopAnimation("sit");
llStartAnimation("dance1");
hidden = TRUE;
{
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
}
}
else
{
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
}
}
}
else if(change & CHANGED_LINK)
{
hidden = FALSE;
{
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
}
}
}
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit");
llStartAnimation("dance1");
hidden = TRUE;
{
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
}
}
}

touch_start(integer total_number)
{
if(hidden)
{
hidden = FALSE;
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
}
else
{
hidden = TRUE;
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
}
}
}


Once again, thank whomever for helping my learning process.
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
01-01-2007 10:48
You have the following structure:

CODE

If (changed & CHANGED_LINK) {
.
[section A]
.
} else if (changed & CHANGED_LINK) {
.
[section B]
.
}


In this case section B will never run, because if (changed & CHANGED_LINK) is true, the section after the if runs. The section after else only runs if the condition (changed & CHANGED_LINK) is false - and then, when it is tested again by the if statement within the else, it is still false so the if doesn't run.

What you probably mean is:

CODE

if (changed & CHANGED_LINK) {
if (set of conditions for A} {
.
.
} else if (set of conditions for B) {
.
.
}
}
Domneth Dingson
Registered User
Join date: 20 Nov 2006
Posts: 126
01-01-2007 11:15
Oooh, Okay. I see now. Thanks so much for pointing that out, that just fixed like 5 things I'm working on, including the above project. (lol)

CODE

integer hidden = FALSE;

default
{
state_entry()
{
llSitTarget(<0,0,.1>, ZERO_ROTATION);
llSetSitText("Pose!");
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
key avataronsittarget = llAvatarOnSitTarget();
if( avataronsittarget != NULL_KEY )
{
if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget)
{
llStopAnimation("sit");
llStartAnimation("dance1");
hidden = TRUE;
{
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
}
}
else
{
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
}
}
else if(change & CHANGED_LINK)
{
hidden = FALSE;
{
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
}
}
}
}
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit");
llStartAnimation("dance1");
hidden = TRUE;
{
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
}
}
}

touch_start(integer total_number)
{
if(hidden)
{
hidden = FALSE;
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
}
else
{
hidden = TRUE;
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
}
}
}


The above works now. ^^

Edit: I just wanted to reiterate a 'thank you' for helping me out. ^^