Cascading Timers
Sometimes you want to program several events to happen in a sequence. You can do this using multiple timers, by setting up the back or end event of one timer to trigger the start message of another.This more advanced example builds on the Opening a Door example. The door is controlled by a timer node which animates it opening; this timer is started by a pointAtTrigger, so the door will begin moving when you click on it.
Additionally, there is now a room behind the door with a separate light; after the door opens, the outside light fades to black, and then the red light inside the room fades in. This is done by cascading the three timers together.
/* door_animated.scene an example demonstrating chaining timers together to make complex sequences of motion point at the door and click to make it open after it swings open, the outside light fades out after that, the inside light turns on so, the chain of events is pointAtTrigger -> door_animator -> light1_animator -> redlight_animator note the initial value of the redlight node - it has a color of -1 -1 -1! this is a "negative light" or "darklight" - it sucks light out of the scene. it's used here to make the inside room dark to begin with; lights travel through walls, so the outside light would initially illuminate the inside room. bcchang 04/04 */ #include "User0" light light1 ((0 0 10 1)) object (("wall.b3d"),(0 10 0)) pointAtTrigger (when(button1,door_animator.)) { object door (("door.b3d"),(0 10 0)) } timer door_animator ((3),(0),(45), when(changed,door.(0 0 $value)), when(,light1_animator.)) timer light1_animator ((5),(1 1 1),(.3 .3 .3), when(changed,light1.($value $value1 $value2)), when(,redlight_animator.)) object (("whiteroom.b3d"),(0 19 0)) light redlight ((0 15 3 1),(-1 -1 -1)) timer redlight_animator ((5),(-1 -1 -1),(1 0 0), when(changed,redlight.($value $value1 $value2)))
(c) Ben Chang