//This script modified from a script by AngryBeth Shortbread. Many Thanks!
// Slight tweak by nand Nerd
key agent; //Identify the agent.
key last_agent; //Used to store the agent's key between calls.
vector pos = <-0.25,0,0.8>; //adjust the position to fit object -must be
//nonzero in at least one direction or script will not work!
rotation rot = <0,0,0,1>; //adjust rotation (1 in any vector gives 90 deg)
default
{
state_entry()
{
llSitTarget(pos, rot); //Place the agent on the seat at the correct position and rotation.
}
changed(integer change) //The agent did something.
{
if (change & CHANGED_LINK)
{
agent = llAvatarOnSitTarget(); //Is a new agent sitting?
{
if ((agent != NULL_KEY) && (agent != last_agent)) //Yes, get permissions to do things.
{
last_agent = agent; //store this for the next changed event.
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
else if ((agent == NULL_KEY) && (last_agent != NULL_KEY))//No, last_agent has stood up, reset all to normal.
{
last_agent = NULL_KEY; // empty the variable, kinda useless since we reset the script but included for completeness
llReleaseControls();
llResetScript();
}
}
}
}
run_time_permissions(integer perm)
{
if(perm) //We got permissions to animate the agent.
{
llStopAnimation("sit"

; //Cancel default sit position
llStartAnimation("sit_ground"

; //And substitute this one instead.
}
else //We do not or no longer have permissions to animate the agent.
{
sendMessage = 0;
llUnSit(agent); //Make the agent stand up.
}
if (perm & PERMISSION_TAKE_CONTROLS) //Reassign keys to do what we want. Inform the agent.
{
llTakeControls(CONTROL_UP | CONTROL_DOWN | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT, TRUE, FALSE);
llInstantMessage(agent, "Press the fly up (PAGE UP) key to raise your hand."

;
llInstantMessage(agent, "Press the fly down (PAGE DOWN) key to lower your hand."

;
}
}
control(key id, integer held, integer change)
{
if (change & CONTROL_UP) //Hand was raised.
{
llStartAnimation("raisehand"

;
llSetTimerEvent(30.0); //After 30 seconds, lower the hand automatically. See the timer() function below.
}
if (change & CONTROL_DOWN) //Hand was lowered.
{
llSetTimerEvent(0.0);
llStopAnimation("raisehand"

;
llStopAnimation("lowerhand"

;
}
}
timer() //Teacher is NOT paying attention. Cancel the raised hand.
{
llSetTimerEvent(0.0);
llStopAnimation("raisehand"

;
}
}