// Sets a sit target and plays whatever animation is
// stored in the contents on the prim when someone sits down.
//
// Kimm Paulino
// Written for Synonyme Toll, April 2010
// These numbers are totally dependent on the object containing
// the script, and possibly even the animation to be used too.
vector gPosition = <0.0, 0.0, 0.1>;
vector gRotation = <0.0, 0.0, 0.0>; // in degrees
default
{
on_rez (integer start_param)
{
llResetScript();
}
state_entry()
{
// These numbers are totally dependent on the object containing the script!
llSitTarget (gPosition, llEuler2Rot (gRotation * DEG_TO_RAD));
}
changed (integer change)
{
// When someone sits on an object, the av is considered to be
// a linked-in child prim, so the link number changes
if (change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();
if (av)
{
// yes so need to play the animation
// first request permissions - results in the callback ...
llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
}
}
}
run_time_permissions(integer perms)
{
// Do we have permissions to run the animations?
// results in the timer!
if(perms)
{
llSetTimerEvent(1.0);
}
else
{
llSetTimerEvent(0.0);
}
}
timer()
{
key av = llAvatarOnSitTarget();
// If the av is still sitting, play the animation stored in the prim
if (av)
{
llStopAnimation("sit");
llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0 ));
}
else
{
// stop playing the animations for sitting if the av
// is no longer sitting ...
llStopAnimation("sit_generic");
llSetTimerEvent(0.0);
}
}
}