Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

problem with llSitTarget

Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
03-11-2007 08:37
i have a problem with the scipt below. I use a prim with 6 different sit animations and
everytime i go sit on it the script use at random a different animation with its own Positition and Rotation.

The problem is that the script use the postition and Rotation from the animation previous animation and not the current position and rotation.

does anyone know how i can solve this.

[PHP

vector POSITION =<-1.15, 0.0, 0.1>;
vector Rotdeg = <0,270,0>;
string SitAnim;
integer randomSit;

default
{
state_entry()
{
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
integer perm=llGetPermissions();
if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(SitAnim)>0)
llStopAnimation("sit";);
llStopAnimation(SitAnim);
SitAnim="";
}
}
}
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{

randomSit = (integer)llRound(llFrand (5));

if(randomSit == 0)
{
vector POSITION=<-1.15, 0, 0.1>;
vector Rotdeg = <0,270,0>;
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}

else if(randomSit == 1)
{
vector POSITION=<-1.15, 0, -0.6>;
vector Rotdeg = <0,270,0>;
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}

else if(randomSit == 2)
{
vector POSITION=<-0.95, 0, -0.28>;
vector Rotdeg = <0,270,0>;
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}
else if(randomSit == 3)
{
vector POSITION=<-1.07, 0, -0.4>;
vector Rotdeg = <0,270,0>;
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}
else if(randomSit == 4)
{
vector POSITION=<-1.45, 0, -0.4>;
vector Rotdeg = <0,270,0>;
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}
else
{
vector POSITION=<-1.07, 0.70, -0.4>;
vector Rotdeg = <0,270,0>;
llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD));
}

SitAnim=llGetInventoryName(INVENTORY_ANIMATION,randomSit);

llStopAnimation("sit";);
llStopAnimation(SitAnim);
llStartAnimation(SitAnim);
llSay(0, (string)randomSit + ":" + SitAnim);

}
}
}
[/PHP]
Venusvelvet Cazalet
Registered User
Join date: 22 Feb 2007
Posts: 16
03-11-2007 20:52
maybe you have to reset the script llResetScript() somewhere, coz each time you sit on the chair, it remebers the state. So if you reset the script, it should have another randomSit.