At

From DeltaWiki
Revision as of 01:25, 5 May 2023 by Xan (talk | contribs) (Created page with "{{feature|1164|5.1}} The '''at''' trigger will activate commands after a set amount of time, or at a scheduled time in VRT. This trigger was added in version 5.1 in conjunction with the timer command 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 animate command. ==Usage== '''at''' tm ''tmName'' ''time-coun...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
At
Build

1164

Version

5.1

The at trigger will activate commands after a set amount of time, or at a scheduled time in VRT. This trigger was added in version 5.1 in conjunction with the timer command 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 animate command.

Usage

at tm tmName time-count [loop], <command>
at VRT hh:mm:ss, <command>

Description

Execute an action command when a timer reaches a certain time-count.

loop-option

The option loop tells the at trigger to repeat the trigger in an interval given by time-counter. For example, if time-count is set to 1000, it will repeat the command at 1000, 2000, 3000, etc until the timer stops.

Examples

Timers

create timer ABC 10000 loop=3; at tm ABC 1000, color red

The at trigger is intended to be used in conjunction with the timer command. 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.

Multiple Events With A Single Timer

create timer ABC2 5000 loop=3; at tm ABC2 1000, noise sound1.wav;at tm ABC2 2500, noise sound2.wav;at tm ABC2 5000, noise sound3.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 sound2.wav, and each time it hits 5000 it will play sound3.wav. In this example, each sound plays three times, in an alternating pattern.


Example, looping at-trigger and stopping a timer:

 activate timer TIMI "-1" reset;  at tm TIMI 1500 loop,  move 1 1 1 smooth time=.5;  at tm TIMI 16500, timer TIMI stop;

Here we set an infinite timer ("-1"), not to worry about the total time. The option reset with the timer just tells it to allow multiple click-starts for re-activating the whole timer.

The first at-trigger is set to loop, repeating the command(s) every 1500 ms (1.5 seconds). The second at-trigger will stop the timer named TIMI, and halt further animation of the object.

Note, if you want to repeat the action exactly 10 times, you have to stop the trigger at 1500 + 1500*10 (16500), since the first animation will be applied at 1500 not at 0. Also, the order of the at-trigger matters here, since if the timer was stopped in the 1st at-trigger, the timer would be dead in the 2nd at-trigger already.

Alternative representation of this example's logic:

// infinite timer (endless loop)
while (++counter) {
  // 1st at-trigger:
  if (counter % 1500 == 0)
    execute("move 1 1 1 smooth time=.5");
  // 2nd at-trigger:
  if (counter == 16500)
    break;
}

The last example is equivalent to: definite timer, no explicit stop required:

activate timer TIMJ 16500 reset;  at tm TIMJ 1500 loop,  move 1 1 1 smooth time=.5;

Scheduled Events

Scheduled Events can be based on VRT time. "VRT" is a special word, always referring to the universe clock, scheduled for a certain time, or scheduled for a specified repeating interval synchronized to the universe clock. If "VRT" is used for the reference name to a timer, the "create timer" statement is not needed, and ignored when used, what also renders a "create timer VRT..." statement invalid consequently.

To schedule an event to be triggered daily at 6pm VRT use (time given in 24 hour format):

at VRT 18:00:00, <command>

To schedule an event to be triggered once an hour, 20 minutes after each full hour use:

at VRT hh:20:00, <command>
or
at VRT :20:00, <command>

To schedule an event to be triggered every minute, 10 seconds after each full minute use:

at VRT hh:mm:10, <command>
or
at VRT ::10, <command>
Object Scripting

Building2.jpg

Triggers: CreateBumpActivateAdoneAtCollideSdoneEnter ZoneExit Zone

Commands: AddforceAddtorqueAlpharefAnimateAstartAstopCameraColliderColltagColorCoronaEnviExamineFrameGroupLightLinkLockMatfxMediaMidiMoveNameNoiseOpacityPictureRotateSayScale SeqShadowShearSignSkewSkyboxSolidSoundTagTeleport / TeleportxTextureTimerURLVelocityVisibleWarpWeb