Skip to content

Delays

In NextFTC there are two types of delays.

Delay

A Delay is a command that waits a certain amount of time before finishing. It takes a TimeSpan to determine how long it will take. Alternatively, it can take a time in seconds.

kotlin
// it can take a TimeSpan:
Delay(5.sec)
Delay(500.ms)

// or a time in seconds, as an Int or a Double
Delay(5)
Delay(5.0)

WaitUntil

WaitUntil evaluates a check every loop and ends when it returns true.

kotlin
WaitUntil { false } // never ends

Delay Utilities

There are a few utilities that help you write common delays more easily.

endAfter

endAfter returns a ParallelRaceGroup with the command and a Delay. This causes the command to have a maximum time it can be before it ends.

kotlin
// All are equivalent
command.endAfter(2.sec)
command.endAfter(2000.ms)
command.endAfter(2)
command.endAfter(2.0)
ParallelRaceGroup(
    command,
    Delay(2.sec)
)

afterTime

afterTime returns a SequentialGroup with a Delay and then the command. This causes the command to wait a certain amount of time before starting.

kotlin
// All are equivalent
command.afterTime(2.sec)
command.afterTime(2000.ms)
command.afterTime(2)
command.afterTime(2.0)
SequentialGroup(
    Delay(2.sec),
    command
)

thenWait

thenWait is like afterTime, but the opposite! thenWait returns a SequentialGroup with the command and then a Delay.

kotlin
// All are equivalent
command.thenWait(2.sec)
command.thenWait(2000.ms)
command.thenWait(2)
command.thenWait(2.0)
SequentialGroup(
    command,
    Delay(2.sec)
)

NOTE

See the delays reference for more information.