Page 1 of 1

Can Animation Callbacks Change SDL Variables?

PostPosted: Tue Oct 20, 2009 11:06 am
by Robert The Rebuilder
I'd like to have the callback of an avatar animation trigger the change in an SDL variable. However, there are no command messages that do this directly. Is there some indirect way to do this, e.g. via notifymsg?

Note: I don't want the avatar animation to trigger in response to the SDL variable change, as it is in the Saving Object Animations' States example - because I don't want other players in the age to suddenly find themselves pulling the same lever as me. :)

Re: Can Animation Callbacks Change SDL Variables?

PostPosted: Tue Oct 20, 2009 11:34 am
by D'Lanor
Robert The Rebuilder wrote:I'd like to have the callback of an avatar animation trigger the change in an SDL variable. However, there are no command messages that do this directly. Is there some indirect way to do this, e.g. via notifymsg?

Not that I know of. I have been running into similar problems lately trying to make callbacks work across different responders.

Robert The Rebuilder wrote:Note: I don't want the avatar animation to trigger in response to the SDL variable change, as it is in the Saving Object Animations' States example - because I don't want other players in the age to suddenly find themselves pulling the same lever as me. :)

Trust me, they won't. Just use Cyan's global Python files and you will be ok. For example xAgeSDLBoolRespond.py. Take a look at its code and you'll see that it does retrieve the avatar who pulls the lever and runs the responder on it correctly.

Re: Can Animation Callbacks Change SDL Variables?

PostPosted: Tue Oct 20, 2009 12:15 pm
by Robert The Rebuilder
D'Lanor wrote:Trust me, they won't. Just use Cyan's global Python files and you will be ok. For example xAgeSDLBoolRespond.py. Take a look at its code and you'll see that it does retrieve the avatar who pulls the lever and runs the responder on it correctly.


So, how will Plasma know to only run the oneshotmsg for the avatar pulling the lever, but run the rest of the responder's messages for everyone?

Shouldn't the oneshotmsg actually be in a separate responder that's triggered by the AutoClick modifier?

Re: Can Animation Callbacks Change SDL Variables?

PostPosted: Tue Oct 20, 2009 1:00 pm
by D'Lanor
Others run the responder as well but not on their own avatar (edit: the avatar ID is sent along with the SDL notify). So no problem there. In fact that is what makes you see the other avatar doing the animation.

Responders are netpropagated by default but not netforced. That would be risky because you would be forcing another player to do an animation. And even that situation only becomes a problem with lag. Have you ever experienced your avatar doing an animation twice? That was unwanted netforcing.

The best practice IMO however is to neither netforce nor netpropagate a responder so that all players run it in their own clients in response to the sdl change.

Re: Can Animation Callbacks Change SDL Variables?

PostPosted: Tue Oct 20, 2009 6:45 pm
by Robert The Rebuilder
Gotcha.

Now to return to the original issue. What I'm trying to do is make it so that the SDL change occurs at the right point in the animation. Lacking a way to trigger this from the callback, I guess I could start the oneshot immediately, then trigger the SDL toggle to occur some period of time later. The time period would be at least as long as the oneshot animation, plus a few more seconds to allow for the avatar seek time. It wouldn't match up, but at least the SDL variable would toggle after the animation instead of simultaneously.

Re: Can Animation Callbacks Change SDL Variables?

PostPosted: Wed Oct 21, 2009 4:58 am
by D'Lanor
I ended up adding a timer callback message at the beginning of the second responder, the one that is triggered by the SDL change. So both the responder with the oneshot and the second SDL triggered responder would start at the same time. The timer attempts to correct for the oneshot plus seektime. Unfortunately this method is not very reliable because seektimes vary considerably. This can be limited somewhat by adding a facing condition and accurate placement of the click region.

My problem is that the second responder is conditional. Depending on several sdl states I need to be able to pick different responders following the one with the oneshot. So placing everything into one responder was not an option.