Using the timer node

The duration message tells the timer how long it should run, in seconds.
The start message makes the timer start running. if you want the timer to begin automatically when the scene loads, include it in the node definition. If you want the timer to start in response to an event, leave it out of the node definition and send the message from another node, like a trigger.
The back event is triggered when the timer is finished. front and back refer to the starting and ending points of a timer, and can also be used as messages to set the timer to the front or back.

To make a timer loop, you want it to start again when it reaches the back:

// a 5 second timer
timer (duration(5.0),when(back,print("timer finished")),start)

You can also make the timer go back and forth between the front and back.
the reverse message makes the timer play backwards. the front event is triggered when the timer reaches the beginning, and the start message starts it playing forwards again.

// a 1 second back-and-forth timer

timer clock (duration(1.0),start,
		when(back,print("tick"),reverse),
		when(front,print("tock"),start)
	)

A simple use of the timer is to repeatedly move an object between two positions. We can do this by sending a message to an object node when the timer reaches the front or back. To try out these examples, make a simple object to represent a clock hand, or download this example file: clockhand.pfb.

// ticking clock, with geometry

light (position(.5 -1 1))

timer clock (duration(1.0),start,
		when(back,clockhand.orientation(0 -45 0),reverse),
		when(front,clockhand.orientation(0 45 0),forward)
	)

object clockhand (file(clockhand.pfb),position(0 5 5),orientation(0 45 0))

(c) Ben Chang