Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Laz-E-Boy script anim bug

raven Blair
Registered User
Join date: 2 Feb 2004
Posts: 39
05-24-2008 06:54
Hi, I have been working on this script for a few days now and keep getting this odd bug where when i click my recliner sometimes the reclined animation wont start, it looks like it starts to kick in then right away goes back to the just sitting there animation. Im still not that great at scripting and it may be something very simple idk.

CODE

key avatar = NULL_KEY;
vector pos = <-0.2,0,-0.2>;
integer on;
string sittext = "";

string gAnimName = "laz-e-boy";
string gAnimName2 = "laz-e-boy1";
default
{
state_entry()
{
llSitTarget(pos, ZERO_ROTATION);
llSetSitText(sittext);
llSetCameraEyeOffset(<-5.0, 0.0, 2.0>);
llSetCameraAtOffset(<3.0, 0.0, 2.0>);
}

changed(integer change)
{
avatar = llAvatarOnSitTarget();
if(change & CHANGED_LINK)
{
if(avatar == NULL_KEY)
{
//sets the chair back to non reclined when someone stands up wile reclined.
llStopAnimation(gAnimName);
llStopAnimation(gAnimName2);
on = FALSE;
llMessageLinked(LINK_SET, on, "","");
llResetScript();
}
else if(avatar == llAvatarOnSitTarget())
{
llSetAlpha(1.0,ALL_SIDES);
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION );
}
}
if (change & CHANGED_INVENTORY)
{
llResetScript();
}

}

on_rez(integer num){
llResetScript();
}

run_time_permissions(integer perms)
{
if(perms)
{
llStopAnimation("sit");
llStartAnimation(gAnimName2);
}
else
{
llUnSit(avatar);
llResetScript();
}
}
//below is the part of the script that starts the reclined animation and makes the chair look
//as if it has reclined by sending link messages to other scripts in the chair.
touch_start(integer total_number)
{
if(on)
{
on = FALSE;
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION );
llStopAnimation(gAnimName);
llMessageLinked(LINK_SET, on, "","");
llStartAnimation(gAnimName2);

}
else
{
on = TRUE;
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION );
llStopAnimation(gAnimName2);
llMessageLinked(LINK_SET, on, "","");
llStartAnimation(gAnimName);

}
}
}


PS. there is a plugin for firefox that lets you read the
CODE
 in script format,,, anyone know where i can get that?
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
05-24-2008 07:28
From: raven Blair
PS. there is a plugin for firefox that lets you read the
CODE
 in script format,,, anyone know where i can get that?


I dunno what's wrong with your chair.. but here's the link to that bbcode workaround:
http://forums.secondlife.com/showthread.php?p=1927640#post1927640
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
05-24-2008 07:57
Each time you issue the llRequestPermissions a run_time_permissions event will be queued.

This first happens when the agent sits... which is fine. However, it will also happen each time the agent clicks (touch._start).

So you might get...

from touch_start:
llStopAnimation(gAnimName2);
llStartAnimation(gAnimName);
:
from run_time_permissions:
llStopAnimation("sit";);
llStartAnimation(gAnimName2);

I'd suggest getting rid of the llRequestPermissions in the touch_start (the permissions having already been set from changed).

My only hesitation is that you say it only 'sometimes' fails. If my theory is correct I'd expect it to always end up with: gAnimName2. :D
raven Blair
Registered User
Join date: 2 Feb 2004
Posts: 39
working
05-25-2008 13:01
great ya i took those out and made a few other changes in the script and it works great now. thanks for the tip :D