I'm hardly a scripting guru but I have been editing this script and somehow managed to get the animations to stop when I am on the ground (it didn't at first). The problem that I keep having is that I can't predict which animation will play when I fly.
It usually begins with the horizontal flight animation and then *sometimes* I will start flapping faster (my hovering animation) and then my hovering animation won't stop until I land.
I hope I can get some feedback on this. Thanks a whole bunch!
Here is the code. It still has the notes from the original author in it:
CODE
// Cross Lament's Silly Animate-On-Flying Kludge
integer isFlying = FALSE ;
integer isHovering = FALSE;
integer hasperms = FALSE ;
key lastuser ;
default
{
state_entry()
{
llSetTimerEvent( 2 ) ; // Polling rate, check every couple of seconds
}
timer()
{
integer flystatus = llGetAgentInfo( llGetOwner() ) ;
// if the agent is flying, and the status holder says they're not...
if( ( flystatus & AGENT_FLYING ) && !isFlying && hasperms )
{
isFlying = TRUE ;
llStartAnimation( "flying" ) ;
}
// if the agent is NOT flying, and the status holder says they are...
else if( !( flystatus & AGENT_FLYING ) && isFlying && hasperms )
{
isFlying = FALSE ;
llStopAnimation( "flying" ) ;
}
// if the agent is flying, and the status holder says they're not...
else if( ( flystatus & AGENT_IN_AIR ) && !isHovering && hasperms )
{
isHovering = TRUE ;
llStartAnimation( "hovering2" ) ;
}
// if the agent is NOT flying, and the status holder says they are...
else if( !( flystatus & AGENT_IN_AIR ) && isHovering && hasperms )
{
isHovering = FALSE ;
llStopAnimation( "hovering2" ) ;
}
}
attach( key id )
{
if( ( id != NULL_KEY ) && !hasperms )
{
lastuser = id ;
llRequestPermissions( id, PERMISSION_TRIGGER_ANIMATION ) ;
}
else if( id = NULL_KEY )
{
hasperms = FALSE ;
integer i ;
list animlist = llGetAnimationList( lastuser ) ;
for( i = 0; i < llGetListLength( animlist ); i++ )
{
llStopAnimation( llList2String( animlist, i ) ) ;
}
}
}
run_time_permissions( integer perms )
{
if( perms & PERMISSION_TRIGGER_ANIMATION )
{
hasperms = TRUE ;
}
else
{
llWhisper( 0, "Warning: Animation permission not set!" ) ;
}
}
}