* Introduction * While ActiveWorlds has certainly been well served by the combination of the animate, astart, astop commands and the adone triggers for creating complex, timed sequences the problem has always been that these commands were never really intended for this purpose. These commands relied very heavily on the underlying implementation of an image processing system which could lead to lag if improperly used. The syntax wasn't exactly the most intuitive either since it required almost arcane knowledge of how the animate system worked. Another pitfall was the lack of synchronization capabilities. Timers were introduced to address these pitfalls with the old system commonly known as "AAA." They introduce a new syntax for developing sequenced, timed events, a system that is only reliant on the underlying timer implementation (and not a image system), and the ability to synchronize events with the VRT clock of the browser. While AAA certainly did do a lot on bringing scripted events to ActiveWorlds and hasn't entirely lost its usefulness, timers are now the supported and preferred method of creating sequenced events and the only way of creating clock synchronized events. What exactly are timers? Well what we know as timers are actually split into two parts: - A timer command, which creates a named timer and specifies the duration of a timer and the repeat interval (anywhere from 1 to infinite number of repeats of the timer). It also used to modify existing timers. - A trigger known as "at" which listens to either a named timer or the VRT clock and triggers the following list of commands when the specified condition is met. The goal of this guide is to cover the syntax for both of these systems and to show how they are used and then go into a discussion of advance methods for using timers. * Timer Command * Before using timers a timer must first be created using the timer command. The timer command takes the following form: timer tmName duration [loop=(n)] [stop | reset] [global] The parameters are explained as follows: - trigger: This is the trigger that causes the timer command to be started. It is compatible with all triggers in ActiveWorlds such as create, activate, bump, sdone, and even the at trigger. - tmName: This is the name of the timer being operated on or created. It is similar to how objects can be named using the name command. -- Timer names cannot exceed seven characters in length, if they do the timer will not work. - duration: This is the duration in milliseconds for how long the timer will run before stopping or looping again. - loop: An optional parameter the specifies how many times the timer should restart itself when it has finished. The minimum is 1 and the maximum is infinity, specified by -1. -- (n) is where the number of times the timer should loop is specified (e.g. loop=5 would repeat the timer five times). - stop: Stop is an optional parameter that suspends a timer. It can be specified with a new timer to make the timer start in a suspended state or it can be used to suspend an existing timer so that it doesn't continue ticking. -- When used to suspend an existing timer it is not needed to specify the duration and loop parameters, these are only needed with new timers. If speficied for an existing timer, they are ignored. -- Stop cannot be used in conjunction with reset because they are mutually exclusive. - reset: Resets a timer to 0 where it begins ticking again and a timer can be reset at any time. -- Creating a timer with this option has no effect. -- When used to reset an existing timer it is not needed to specify the duration and loop parameters. - global: An optional parameter that makes the timer creation, stopping, or resetting global (it happens for everyone around the avatar that triggered it). Only useful in the context of activate, bump, enter, and exit triggers. ** Examples ** Now for some examples of using this command. Note that the at trigger is not used. This section is only to illustrate how to use the timer command itself, the at trigger will be discussed later. Also you can recombine the different triggers and examples here to create new and different ways of operating on a timer. *** Example 1: Creating a timer with the create trigger *** create timer abc 1500 This creates a timer, when the object loads, named abc with a duration of 1500ms. *** Example 2: Creating a timer with the create trigger in suspended mode *** create timer xyz 2000 stop This creates a timer, when the object loads, named xyz with a duration of 2000ms and suspends the timer so that it doesn't execute immediately. *** Example 3: Creating a timer with the bump trigger that starts ticking for everyone *** bump timer pqr 3000 global This creates a timer named pqr with a duration of 3000ms when an avatar bumps the object. It starts ticking for everyone near the avatar. *** Example 4: Suspending a timer with the activate trigger *** activate timer pqr stop This will suspend the ticking of the timer named pqr when a user clicks the object. This is useful for allowing a user to stop some sequenced event. *** Exmaple 5: Suspending a timer with thr bump trigger *** bump timer xyz stop This will suspend the ticking of the timer named xyz when the user bumps the object. An example of using this would be stopping a timer that would have teleported a user after 60 seconds if they had not reached the end of a maze. *** Example 5: Restart a timer at 0 and continue ticking when a user enters a zone *** enter zone bob, timer abc reset This will reset the timer abc to 0 where it will begin ticking once more when the user enters the zone named bob. *** Example 6: Create a timer that loops six times using the create trigger *** create timer asdf 5000 loop=6 This will create a timer named asdf that has a duration of 5000ms, and it will repeat itself in ticking up to 5000ms six times in a row. * At Trigger * Creating, resetting, and even stopping timers is easy enough, but they are useless without some way to respond to them and execute other commands like move, rotate, color, tag, etc. This is where the at trigger comes into play. It allows you to specify a set of parameters for when a given list of commands should be executed by the browser. You can even specify multiple at triggers on a single object (with the exception of VRT based at triggers).