Trigger

class Trigger @JvmOverloads constructor(loop: EventLoop = defaultEventLoop, condition: () -> Boolean) : Function0<Boolean>

This class provides an easy way to link commands to conditions.

It is very easy to link a button to a command. For instance, you could link the trigger button of a joystick to a "score" command.

Triggers can easily be composed for advanced functionality using the [and], [or], [negate] operators.

Constructors

Link copied to clipboard
constructor(loop: EventLoop = defaultEventLoop, condition: () -> Boolean)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun and(trigger: () -> Boolean): Trigger

Composes two triggers with logical AND.

Link copied to clipboard
fun debounce(seconds: Double, type: Debouncer.DebounceType = Debouncer.DebounceType.RISING): Trigger

Creates a new debounced trigger from this trigger - it will become active when this trigger has been active for longer than the specified period.

Link copied to clipboard
Link copied to clipboard
open operator override fun invoke(): Boolean
Link copied to clipboard
fun multiPress(requiredPresses: Int, windowTime: Double): Trigger

Creates a new multi-press trigger from this trigger - it will become active when this trigger has been activated the required number of times within the specified time window.

Link copied to clipboard

Creates a new trigger that is active when this trigger is inactive, i.e. that acts as the negation of this trigger.

Link copied to clipboard
fun onChange(command: Command): Trigger

Starts the command when the condition changes.

Link copied to clipboard
fun onFalse(command: Command): Trigger

Starts the given command whenever the condition changes from true to false.

Link copied to clipboard
fun onTrue(command: Command): Trigger

Starts the given command whenever the condition changes from false to true.

Link copied to clipboard
fun or(trigger: () -> Boolean): Trigger

Composes two triggers with logical OR.

Link copied to clipboard
fun toggleOnFalse(command: Command): Trigger

Toggles a command when the condition changes from true to false.

Link copied to clipboard
fun toggleOnTrue(command: Command): Trigger

Toggles a command when the condition changes from false to true.

Link copied to clipboard
fun whileFalse(command: Command): Trigger

Starts the given command when the condition changes to false and cancels it when the condition changes to true.

Link copied to clipboard
fun whileTrue(command: Command): Trigger

Starts the given command when the condition changes to true and cancels it when the condition changes to false.