CODE
integer d_permacq = FALSE;
key d_agent = NULL_KEY;
string animation;
default
{
state_entry()
{
llSitTarget(<0, 0, 1>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
// Note that if both the vector and the rotation are zero,
// the SitTarget is removed instead of set and the following will not work:
}
changed(integer change)
{ // something changed
if (change & CHANGED_LINK)
{ // and it was a link change
key agent = llAvatarOnSitTarget();
if (d_agent == NULL_KEY && agent != NULL_KEY)
{ // somebody is sitting on me
d_agent = agent;
llRequestPermissions(agent,PERMISSION_TRIGGER_ANIMATION);
//llSleep(0.5);
//llRequestPermissions(agent, PERMISSION_TAKE_CONTROLS); // get permission to take controls
llSay(0, "Welcome to Dance Dance Second Life!");
}
else if (d_agent != NULL_KEY && agent == NULL_KEY)
{
//user is getting up
if (d_permacq)
{
//restore anims
llStopAnimation(animation);
}
//reset the script to release permissions
llResetScript();
}
}
}
run_time_permissions(integer parm)
{
if (parm == PERMISSION_TAKE_CONTROLS)
{ // we got a yes
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT, TRUE, FALSE); // take left,right, Forward, and back controls
}
if(parm == PERMISSION_TRIGGER_ANIMATION)
{
//set permission flag
d_permacq = TRUE;
//cancel the sit anim
llStopAnimation("sit");
llStartAnimation("dance start");
animation = "dance start";
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); // get permission to take controls
}
}
control(key id, integer level, integer edge)
{ // something happened to one of our controls
key agent = llAvatarOnSitTarget();
llRequestPermissions(agent,PERMISSION_TRIGGER_ANIMATION);
if ((edge & level & CONTROL_FWD))
{ // the "forward" key is held
llStopAnimation(animation);
llStartAnimation("dance left f");
animation = "dance left f";
}
else if ((edge & level & CONTROL_BACK))
{// the "back" key was pressed
llStopAnimation(animation);
llStartAnimation("dance right b");
animation = "dance right b";
}
else if ((edge & level & CONTROL_ROT_LEFT))
{ // The "left" key was pressed
llStopAnimation(animation);
llStartAnimation("dance left l");
animation = "dance left l";
}
else if ((edge & level & CONTROL_ROT_RIGHT))
{// The "right" key was pressed
llStopAnimation(animation);
llStartAnimation("dance right r");
animation = "dance right r";
}
else
{
llStopAnimation(animation);
llStartAnimation("dance start");
animation = "dance start";
}
}
}
The idea is to click on the pad on the ground.
The avatar moves to the center of the pad and stand still.
then controls need to be taken.
once they are. pressing any of the four arrow keys should change to the appropriate pose.
but all i get is endless permission spam and my avatar flashes at light speed between two poses.
Someone help me out please.