Sit animation override not working in changed event
|
|
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
|
01-13-2007 13:40
I have a script where I set an llSitTarget and then have a changed event handler which is supposed to replace the standard "sit" pose with the "turn_180" "posing" pose. The strange thing is that sometimes it works fine, and sometimes the default "sit" pose is used. I can't reproduce the problem often enough to figure out what's not working. Are permissiongs not being granted in time (although, I thought selecting "sit" off the pie menu was supposed to automaatically grant the permission). Or, do I need a delay between the llStopAnimation and the llStartAnimation? Any suggestions? changed(integer iChange) { if (iChange & CHANGED_LINK) // triggered by sit / unsit, as well as link changes { key agent = llAvatarOnSitTarget(); if ( kAgentSitting == NULL_KEY && agent != NULL_KEY ) // agent just sat on empty spot { kAgentSitting = agent; llRequestPermissions(kAgentSitting, PERMISSION_TRIGGER_ANIMATION); if ( llGetPermissions() & PERMISSION_TRIGGER_ANIMATION ) { llStopAnimation("sit"); llStartAnimation("turn_180"); } } else if ( kAgentSitting != NULL_KEY && agent == NULL_KEY) // someone who was sitting got up { if ( llGetPermissions() & PERMISSION_TRIGGER_ANIMATION ) llStopAnimation("turn_180"); } } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-13-2007 14:27
I usually handle the animation in the permissions event rather than the changed event changed(integer change) { // something changed if (change & CHANGED_LINK) { // and it was a link change if (llAvatarOnSitTarget() != NULL_KEY && receiver == NULL_KEY) { receiver = llAvatarOnSitTarget(); // store sitting avatar's key llRequestPermissions(receiver, PERMISSION_TRIGGER_ANIMATION ); } else if( receiver != NULL_KEY ) { // if the avatar has gotten up llStopAnimation(animation); } } } run_time_permissions(integer perms) { if( (perms & PERMISSION_TRIGGER_ANIMATION) == PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("sit"); llStartAnimation(animation); } }
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
01-14-2007 02:26
According to the wiki, llAvatarOnSitTarget will not detect the av unless the script has set the sit target. Dunno why, but when I put in the sit target command in the state_entry() code, it suddenly worked! see: http://rpgstats.com/wiki/index.php?title=LlAvatarOnSitTargetfor: From: someone This will only detect avatars sitting on sit targets defined with llSitTarget. At some point prior to SL 1.6.5, it would apparently work without, but has apparently not been the case for some time. Scripts compiled prior to the change will function correctly, but recompiling them will cause them to break.
|
|
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
|
01-14-2007 05:17
Thanks for the suggestion, Newgate -- I'll try shifting it into the permissions event. Having it in the permissions event, though, seems like it would be problematic if the script had multiple areas where different animations were wanted, which would probably require using globals to keep track of what the desired animations was. Also, it would require that the permissions event fires whenever " llRequestPermissions(receiver, PERMISSION_TRIGGER_ANIMATION )" was requested, even if the permission has already previously been granted -- is that the case? ===== From: someone According to the wiki, llAvatarOnSitTarget will not detect the av unless the script has set the sit target. Dunno why, but when I put in the sit target command in the state_entry() code, it suddenly worked! Yes, that's right. I only posted the problematic snippet of my code, but mentioned in passing that I did set llSitTarget to make sure it detected the change: From: someone I have a script where I set an llSitTarget and then have a changed event handler The weird thing is that SOMETIMES my sit override works fine, and SOMETIMES the default sit animation is used. This suggests to me that it might be a problem with timing / current lag in the sim / something not necessarily directly script related. Perhaps Newgate's suggestion would make the script less susceiptible to these unpredictable failures. What do pose stands do, because that's basically what I'm trying to replicate?
|
|
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
|
01-14-2007 13:49
Never mind, it didn't work because I left out a line. When the avatar gets up, I needed to put in a: kAgentSitting = NULL_KEY; This became clear, when I realized the bug was perfectly reproducible: it always worked the first time, and never again until script reset. Moral: don't blame "weird timing / lag / whatever", when it's most likely something more mundane, like the scripter messing up.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-15-2007 02:50
From: Ged Larsen Never mind, it didn't work because I left out a line. When the avatar gets up, I needed to put in a: kAgentSitting = NULL_KEY; This became clear, when I realized the bug was perfectly reproducible: it always worked the first time, and never again until script reset. Moral: don't blame "weird timing / lag / whatever", when it's most likely something more mundane, like the scripter messing up. We all do it Ged, the number of times I've had a working script that has been broken by a stupid cut and paste error or simple over sight. And since we know it was working it HAS to be SL .....
|
|
Furia Freeloader
Furiously Furia
Join date: 13 Dec 2005
Posts: 34
|
01-16-2007 10:47
These kinds of bugs, that have to do with scripts already running, or changing owner, are a huge pain to track down! They are the most annoying kind.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-16-2007 11:13
From: Furia Freeloader These kinds of bugs, that have to do with scripts already running, or changing owner, are a huge pain to track down! They are the most annoying kind. Changes in ownership bugs are some of the most common beginners mistakes. Its good practise to add a changed event handler to ensure you deal with the situation.
|