string anim_name; // added this animation as a global
/////////// USER SETTINGS ////////////////////
string floattext = "Sit Here";
string sittext = "Pose!";
vector textcolor = <1,1,1>;
vector sittarget = <0,0,1>;
vector sitangle = <0.0,0.0,0.0>;
integer listen_handle;
//////////// BEGIN SCRIPT ////////////////////
rotation sitrotation;
default
{
on_rez( integer sparam )
{
llResetScript();
}
state_entry()
{
anim_name = llGetInventoryName(INVENTORY_ANIMATION,0); // defined the variable anim_name .. in this case the first animation found in inventory
listen_handle = llListen(1, "", llGetOwner(), "");
sitrotation = llEuler2Rot(sitangle * DEG_TO_RAD); // convert the degrees to radians, then convert that vector into a rotation
llSitTarget(sittarget, sitrotation);
llSetText(floattext, textcolor, 0.8);
llSetSitText(sittext);
}
changed(integer change)
{
if(change & CHANGED_LINK) // If someone has sat on, or "linked," to this prim...
{
key avataronsittarget = llAvatarOnSitTarget();
if( avataronsittarget != NULL_KEY ) //Someone is sitting on the object
{
llSetText("", textcolor, 0.8);
llSetLinkAlpha(LINK_SET,0,ALL_SIDES); // Turn Invisible
// Before animating, first check if we have permission to do so:
if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget) {
// If we do, we can animate:
llStopAnimation("sit");
llStartAnimation(anim_name);
} else {
// If we dont, ask for them:
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
// We'll animate in the run_time_permissions event, which is triggered
// When the user accepts or declines the permissions request.
}
}
else //stood up
{
llSetText(floattext, textcolor, 0.8);
llSetLinkAlpha(LINK_SET,1,ALL_SIDES); // Make Visible
}
}
}
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit");
llStartAnimation(anim_name);
}
}
listen( integer channel, string name, key id, string message )
{
if (message == "restart")
{
llStopAnimation(anim_name);
llStartAnimation("sit");
llSleep(0.1);
llStopAnimation("sit");
llStartAnimation(anim_name); // if you use an 1 instead of a 0 WORKS, why!?!?! and how can i resolve my problem?
}
}
}