Can Animation Callbacks Change SDL Variables?

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Can Animation Callbacks Change SDL Variables?

Postby Robert The Rebuilder » Tue Oct 20, 2009 11:06 am

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. :)
Can we rebuild it? Yes, we can - here's how.

MOULagain KI# 1299

Myst Movie coming soon - spread the word!
User avatar
Robert The Rebuilder
 
Posts: 1383
Joined: Sat Sep 29, 2007 7:24 am
Location: Virginia, US

Re: Can Animation Callbacks Change SDL Variables?

Postby D'Lanor » Tue Oct 20, 2009 11:34 am

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.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Can Animation Callbacks Change SDL Variables?

Postby Robert The Rebuilder » Tue Oct 20, 2009 12:15 pm

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?
Can we rebuild it? Yes, we can - here's how.

MOULagain KI# 1299

Myst Movie coming soon - spread the word!
User avatar
Robert The Rebuilder
 
Posts: 1383
Joined: Sat Sep 29, 2007 7:24 am
Location: Virginia, US

Re: Can Animation Callbacks Change SDL Variables?

Postby D'Lanor » Tue Oct 20, 2009 1:00 pm

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.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Can Animation Callbacks Change SDL Variables?

Postby Robert The Rebuilder » Tue Oct 20, 2009 6:45 pm

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.
Can we rebuild it? Yes, we can - here's how.

MOULagain KI# 1299

Myst Movie coming soon - spread the word!
User avatar
Robert The Rebuilder
 
Posts: 1383
Joined: Sat Sep 29, 2007 7:24 am
Location: Virginia, US

Re: Can Animation Callbacks Change SDL Variables?

Postby D'Lanor » Wed Oct 21, 2009 4:58 am

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.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron