Timer

From ActiveWiki
Jump to: navigation, search
Timer
Build

1162

Version

5.1

The timer command creates a timer in memory that allows a user to activate events after a set amount of time. This trigger was added in version 5.1 in conjunction with the at trigger as an easier and more accessible way for users to create timed events. Previously, builders could only create timed events by a complicated workaround using the depreciated animate command.

Usage

timer tmName duration [loop=1] [stop | reset] [global]

duration

The duration is the lifetime of the timer. The timer starts to count at 0 and ends at the time specified by duration. During this lifetime at triggers may call their events. The unit for the duration is milliseconds. The minimum value is 100. You can also set it to "-1" which will cause the timer to count to infinity. Note, double quotes are required for infinite duration.

loop

The loop option can be used to start over once the duration has expired. The minimum count of loops is 1. An infinite count of loops can be defined by using -1 (no quotes needed).

stop

The stop option halts a timer, but does not terminate or destroy the timer. A stopped timer can be restarted at anytime using the reset option. A timer can be created in suspended mode by using the stop option when the timer is created. This essentially pauses the timer before it is able to begin counting. When referencing an already running timer, the duration and the loop is not needed, and if a duration and/or loop is given, they are ignored. The options stop and reset are mutually exclusive.

reset

The reset option restarts a timer to start counting from zero. All dependent at triggers are reset as well. An existing timer can be reset at any time. Creating a timer with the reset option has no effect. The options reset and stop are mutually exclusive.

global

The global option can be used (starting with build 1172) to create, reset or stop a timer for all avatars that have it within visibility range. This is only effective when used in conjunction with an activate or bump trigger.

Examples

Timers

create timer ABC 10000 loop=3;  at tm ABC 10000, color red
  • The timer command is intended to be used in conjunction with the at trigger. The example above details the use of the create trigger to create a timer and the at trigger to activate the desired command—or effect—of the timer.
  • The at trigger can also be used more than once
  • tmName cannot exceed seven characters in length. If it does, the timer will not work.
  • Duration is written in milliseconds. The '10000' in the example above is 10 seconds.


create timer ABC "-1"; at tm ABC 3333 loop, color red; at tm ABC 6666 loop, color yellow; at tm ABC 9999 loop, color green;

This example shows a simple traffic light.

Multiple events with a single timer

create timer ABC2 5000 loop=3; at tm ABC2 2500, noise sound1.wav;at tm ABC2 5000, noise sound2.wav'

This example shows you that multiple events can be triggered from a single timer. In this example, when the timer ABC2 is created, it begins counting up to 5000 milliseconds (5 seconds) and then loops three times. Each time the timer hits 2500ms, it will play sound1.wav, and each time it hits 5000 it will play sound2.wav. In this example, each sound plays three times, in an alternating pattern.

Implicit Limits

The total duration of a timer is limited to a minimum of 100 ms and to a maximum of about 50 days (more precise 49.7 days). The lower limit is a result of the time-slice considered by the timer logic and the given duration is clamped to a minimum of 100ms anyway. The upper limit is a result of the capacity used representing the duration value. In practices neither limit shall have an impact on use, as long the continues time spent at a location, without any kind of interrupt, is less than 50 days, what can be safely assumed.

If you still need to run a timer continuously longer than 50 days, that is you'd assume a user standing at the same location longer than 50 days without any interrupt, set the duration to infinite "-1" and the optional loop count to infinite as well, which will extend the total time to about 213.459.874.561 days, more than 584.821.574 years.


Object Scripting

Building2.jpg

Triggers: CreateBumpActivateAdoneAtCollideSdoneEnter ZoneExit Zone

Commands: AddforceAddtorqueAlpharefAnimateAstartAstopCameraColliderColltagColorCoronaEnviExamineFrameGroupLightLinkLockMatfxMediaMidiMoveNameNoiseOpacityPictureRotateSayScale SeqShadowShearSignSkewSolidSoundTagTeleport / TeleportxTextureTimerURLVelocityVisibleWarpWeb