Time Change Callback Mechanism

You can register one or more functions to be called whenever the current 3ds max animation time is changed, such as when the user drags the time slider or plays the animation. The following methods let you register and unregister these callbacks:

registerTimeCallback <fn>

unRegisterTimeCallback <fn>

You can register as many functions as you like. Each one is individually called whenever the time changes. The functions you register must take no arguments. They can access the updated current time through the MAXScript system variable currentTime.

Example

fn time_p = print currentTime

registerTimeCallback time_p

In the above example, the registered function causes the current time to be printed in the Listener window whenever the user moves the time slider or plays the animation.

Special Considerations

fn time_cb = print currentTime

fn tcb = time_cb()

registerTimeCallback tcb

In this case, the registered callback function, tcb, calls the real call back, time_cb, (by referencing the global variable it is defined in), meaning you can redefine time_cb() as often as you need and the callback will always invoke the latest definition. This is a useful technique to employ while you are developing and debugging a callback.